howto fixthis if statement

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • AliHabib
    New Member
    • Dec 2008
    • 11

    #1

    howto fixthis if statement

    I write a code to change variable by this if statement but it not work alwaysgive the else

    Code:
    if request("txtSearch2") = "" then
    
    									
    					'select case sens
    					if request("Sense")= "on" then   
    					sqlPRJ = "SELECT TCKT_ID,TCKT_OPN_DATE,TCKT_DESC FROM TCKTs WHERE TCKT_DESC like '%'+'"&request("txtSearch1")&"'+'%'COLLATE SQL_Latin1_General_CP1_CS_AS"					
    					 else
    					sqlPRJ = "SELECT TCKT_ID,TCKT_OPN_DATE,TCKT_DESC FROM TCKTs WHERE TCKT_DESC like '%'+'"&request("txtSearch1")&"'+'%'"
    					end if
    				end if
  • CroCrew
    Recognized Expert Contributor
    • Jan 2008
    • 564

    #2
    Hello AliHabib,

    Try adding some debugging code like the one below to see what your getting for your values and where you fall into your ‘If Then’ statements.

    Code:
    response.write("This is the value for 'txtSearch2': [" & request("txtSearch2") & "]</br>")
    if request("txtSearch2") = "" then 
    	response.write("This is the value for 'Sense': [" & request("Sense") & "]</br>")
    	
    	if request("Sense")= "on" then    
    		response.write("True")
    	else 
    		response.write("False")
    	end if 
    end if
    Hope this helps,
    CroCrew~

    Comment

    • jhardman
      Recognized Expert Specialist
      • Jan 2007
      • 3405

      #3
      try trimming your request (removes spaces)
      Code:
      if trim(request("txtSearch2")) = "" then
      let me know if this helps.

      Jared

      Comment

      • Nicodemas
        Recognized Expert New Member
        • Nov 2007
        • 164

        #4
        @AliHabib

        Remember that the conditional is going to compare this EXACT test. If the value of request("Sense" ) is being passed along as "on" (note, no leading/trailing spaces, all lowercase) then it should work.

        Try this and see:


        Code:
        if trim(request("txtSearch2")) = "" then 
           'select case sens 
           if lcase(trim(request("Sense")))= "on" then    
              sqlPRJ = "SELECT TCKT_ID,TCKT_OPN_DATE,TCKT_DESC FROM TCKTs WHERE TCKT_DESC like '%'+'"&request("txtSearch1")&"'+'%'COLLATE SQL_Latin1_General_CP1_CS_AS"                     
           else 
              sqlPRJ = "SELECT TCKT_ID,TCKT_OPN_DATE,TCKT_DESC FROM TCKTs WHERE TCKT_DESC like '%'+'"&request("txtSearch1")&"'+'%'" 
           end if 
        end if
        If that does not work, your Request parameter is not correct or you are sending the wrong string in request("Sense" ).

        Comment

        Working...