The Shed is going Social! Join us on FaceBook and Twitter and chime in on the conversation.
|
 |
|
Dev Shed Forums
> Programming Languages - More
> ASP Programming
|
Variables with equal Value aren't Equal?
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.
|
|
 |
|
|
|
|

Dev Shed Forums Sponsor:
|
|
|

December 2nd, 2011, 12:24 PM
|
|
Registered User
|
|
Join Date: Nov 2011
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>
|

December 2nd, 2011, 03:03 PM
|
|
Registered User
|
|
Join Date: Nov 2011
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.
|

December 2nd, 2011, 04:59 PM
|
|
|
|
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
|

December 2nd, 2011, 05:44 PM
|
|
Registered User
|
|
Join Date: Nov 2011
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).
|
Developer Shed Advertisers and Affiliates
| Thread Tools |
Search this Thread |
|
|
|
| Display Modes |
Rate This Thread |
Linear Mode
|
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
|
|