#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Nov 2011
    Posts
    3
    Rep Power
    0

    Variables with equal Value aren't Equal?


    Ok, I am stumped. When I use Response.Write both of the variables are equal (1 = 1 or 2 = 2 etc) but when I use an if statement of if variable A = B, it doesn't register even when they are equal, however if i do an if statement of if A = 1 or if B = 1, it triggers. I am stumped, I think it may be because its a query result value (integer) equaling a form GET querystring variable, however, I have used this same exact setup in other situations and it has worked before, so I dunno. Here is the code, hopefully someone can point out what I did wrong :/

    The code that isn't working is the
    Code:
    <% if Request.querystring("CCRID") = ccrRS("ID") then response.write(" selected") end if%>
    Code:
    <form name="DRILLDOWN2" action="CCR.asp" method="get" style="padding:5px;float:left;">
    		<select name="CCRID" onchange="DRILLDOWN2.submit();" size="5" style="width:275px;">	
    		<%
    dim ccrObj
    set ccrObj=Server.CreateObject("ADODB.Connection")
    ccrObj.open(gsConnectionString)
    const ccrSQL = "SELECT CCR.ID as ID, CCR.NAME as Name, CCRType.Type as Type FROM CCR INNER JOIN CCRType ON CCR.Type = CCRType.ID ORDER BY CCR.Name"
    dim ccrRS
    set ccrRS = Server.CreateObject("ADODB.Recordset")
    ccrRS.Open ccrSQL, ccrObj
    %>
    <%
    Do While not ccrRS.EOF 
    %>
    <option value="<% Response.Write ccrRS("ID") %>"<% if Request.querystring("CCRID") = ccrRS("ID") then response.write(" selected") end if%>><% Response.Write ccrRS("Name") %> - <% Response.Write ccrRS("Type") %></option>
    <%
    ccrRS.MoveNext
    Loop 
    ccrRS.Close
    ccrObj.Close
    %>	
    		</select>
    	</form>
  2. #2
  3. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Nov 2011
    Posts
    3
    Rep Power
    0
    Ok, I changed the code, and also made it to show what the values of the two variables are, still have the same problem, here is the new code-

    Code:
    <form name="DRILLDOWN2" action="CCR.asp" method="get" style="padding:5px;float:left;">
    		<select name="CCRID" onchange="DRILLDOWN2.submit();" size="5" style="width:275px;">	
    		<%
    dim ccrObj
    set ccrObj=Server.CreateObject("ADODB.Connection")
    ccrObj.open(gsConnectionString)
    const ccrSQL = "SELECT CCR.ID as ID, CCR.NAME as Name, CCRType.Type as Type FROM CCR INNER JOIN CCRType ON CCR.Type = CCRType.ID ORDER BY CCR.Type, CCR.Name"
    dim ccrRS
    set ccrRS = Server.CreateObject("ADODB.Recordset")
    ccrRS.Open ccrSQL, ccrObj
    dim ccrRSID
    dim ccrQSID
    ccrQSID = Request.QueryString("CCRID")
    %>
    <%
    Do While not ccrRS.EOF 
    ccrRSID = ccrRS("ID")
    %>
    <option value="<% Response.Write ccrRS("ID") %>"<% if ccrRSID = ccrQSID then response.write(" selected") end if%>><% Response.Write ccrRS("Name") %> - <% Response.Write ccrRS("Type") %> --- <%=ccrRSID%> = <%=ccrQSID%></option>
    <%
    ccrRS.MoveNext
    Loop 
    ccrRS.Close
    ccrObj.Close
    %>	
    		</select>
    	</form>
    And Here is a screen shot, that shows that 3 = 3, and yet the code isn't including the " selected" at the end of the option -.-


    hmmm... The image tag isnt working properly :/
    http://www.sabrelink.com/assets/Problem.jpg

    Also, oddly enough, the second box in the picture, uses the same exact code structure (with different variables, but the same get variable = query variable stucture) and yet it works perfectly fine -.- I really dunno what is going wrong here.
  4. #3
  5. No Profile Picture
    Grumpier old Moderator
    Devshed Supreme Being (6500+ posts)

    Join Date
    Jun 2003
    Posts
    14,443
    Rep Power
    4539
    Add debug probes using response.write <variable I want to see> and verify your variable values are in fact what you expect.
    ======
    Doug G
    ======
    Bartender to Rene Descartes "have another beer?" Descartes: "I think not" and he vanished.
    --Alfred Bester
  6. #4
  7. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Nov 2011
    Posts
    3
    Rep Power
    0
    Originally Posted by Doug G
    Add debug probes using response.write <variable I want to see> and verify your variable values are in fact what you expect.
    Thats what I did in the second post

    Code:
    <option value="<% Response.Write ccrRS("ID") %>"<% if ccrRSID = ccrQSID then response.write(" selected") end if%>><% Response.Write ccrRS("Name") %> - <% Response.Write ccrRS("Type") %> --- <%=ccrRSID%> = <%=ccrQSID%></option>
    Notice the end, shows ccrRSID and ccQSID. Both are functioning as they should, QSID is the QueryString Id (which stays the same) while ccrRSID is the ID of they incremental query return.

    In the image that I posted a link to (the IMG code doesn't seem to want to cooperate with me on this forum) it shows the ccrRSID going from 1 to 3, while the ccQSID stays at 3, and yet, the option 3 is not selected (and in the view source, it does not show selected on any of them).

IMN logo majestic logo threadwatch logo seochat tools logo