Discuss Variables with equal Value aren't Equal? in the ASP Programming forum on Dev Shed. Variables with equal Value aren't Equal? ASP Programming forum discussing Active Server Pages coding techniques and problem solving methods. Use VBScript or Jscript to make dynamic web applications.
Receive the tools necessary to be the rock star of your field. Our 12-month program teaches you the evolving world of multi-channel marketing as well as the complex issues and opportunities found in the industry.
ASP Free and Iron Speed Designer are giving away $5,500+ in FREE licenses. Iron Speed's RAD CASE toolset can save up to 80% of your coding time. One free license per week, one perpetual license per month! Download and Activate to enter!
Web development can be a daunting task, even for specialists. There is a lot of information to absorb and a lot of technologies to learn in order to manage a superior website. When trying to learn the ropes, developers need a reliable source to introduce new ideas that can be easily implemented. When working on large projects, even web veterans may run into a technology or an aspect of a technology that they are unfamiliar with.
Posts: 3
Time spent in forums: 1 h 44 m 2 sec
Reputation 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>
Posts: 3
Time spent in forums: 1 h 44 m 2 sec
Reputation 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 -.-
URL
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.
Posts: 13,894
Time spent in forums: 1 Month 3 Weeks 4 Days 15 h 10 m 20 sec
Reputation Power: 4227
Add debug probes using response.write <variable I want to see> and verify your variable values are in fact what you expect.
__________________
======
Doug G
======
It is a truism of American politics that no man who can win an election deserves to. --Trevanian, from the novel Shibumi
Posts: 3
Time spent in forums: 1 h 44 m 2 sec
Reputation Power: 0
Quote:
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).