Programming Help
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
 
User Name:
Password:
Remember me
Go Back   ASP Free ForumsOtherProgramming Help

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread ASP Free Forums Sponsor:
  #1  
Old May 17th, 2004, 09:43 AM
cptCaveman cptCaveman is offline
Registered User
ASP Free Newbie (0 - 499 posts)
 
Join Date: May 2004
Posts: 3 cptCaveman User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
When 'If' stops working ...

Hope someone can make sense of this on my behalf as I appear to have hit a wall.

Form such as this:

<td><SELECT name="Project">
<OPTION VALUE=0>None Selected
<%
For i = 1 to numProjects
If Not Project(i) = "" Then
Response.Write ("<OPTION VALUE=")
Response.Write (i)
If i = cProject Then
response.write( " SELECTED" )
End If
Response.Write (">")
Response.Write (Project(i) & vbCrLf )
End If
'Move to the next record in the recordset
Next
%></SELECT></td>

where cProject = request.form("Project") is specified at the top.

The problem is in the If statement as it never returns true, even though cProject will always contain a value that matches one of the array indices.
I've changed the statement to IF i = 10 Then and If cProject = 10 Then and both work as expected but the statement just does not work when trying to compare these two values.

Any advice? As a visiter from php scripting, is there something I need to know about asp form variables or data types?

Reply With Quote
  #2  
Old May 17th, 2004, 10:10 AM
Memnoch's Avatar
Memnoch Memnoch is offline
Unholy Moderator
ASP Free God 14th Plane (11500 - 11999 posts)
 
Join Date: Oct 2003
Location: In hell, where did you think?
Posts: 11,760 Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level) 
Time spent in forums: 3 Weeks 5 Days 5 h 22 m 16 sec
Reputation Power: 443
Post more of your code and what you are attempting to do.
You are referencing objects (Project), but we don't know where or what those objects pertain to, so we can't really help you yet.

Reply With Quote
  #3  
Old May 17th, 2004, 10:44 AM
cptCaveman cptCaveman is offline
Registered User
ASP Free Newbie (0 - 499 posts)
 
Join Date: May 2004
Posts: 3 cptCaveman User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
The code is intended to query a database based on user selections in a number of 'SELECT' statements.

After the DB has been queried, I want the page to display all the returned data but also set the select menus tot he values previously selected in case only one of them is to be changed before the next query.

Additions to the earlier code are as follows:
Above original snipet -

dim numProjects
strSQL = "SELECT TOP 1 ProjectID FROM tblProjects ORDER BY ProjectID DESC;"
rsBilling.Open strSQL, adoCon
numProjects = rsBilling("ProjectID")

rsBilling.Close
strSQL = "SELECT ProjectID, Project FROM tblProjects WHERE Active = -1 ORDER BY ProjectID ASC;"
rsBilling.Open strSQL, adoCon
dim Project()
redim preserve Project(numProjects)
Do While not rsBilling.EOF
'Work with info
num = rsBilling("ProjectID")
Project( num ) = rsBIlling("Project")
rsBilling.MoveNext
Loop
rsBilling.Close

How could something outside of i and cProject be effecting the If statement seeing as their actual values have not been effected?

My thanks for any assistance and apologies for the lack of info to start with.

Reply With Quote
  #4  
Old May 17th, 2004, 10:54 AM
Memnoch's Avatar
Memnoch Memnoch is offline
Unholy Moderator
ASP Free God 14th Plane (11500 - 11999 posts)
 
Join Date: Oct 2003
Location: In hell, where did you think?
Posts: 11,760 Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level) 
Time spent in forums: 3 Weeks 5 Days 5 h 22 m 16 sec
Reputation Power: 443
Your code still doesn't make sense.
And I have no idea why you are using an array.
If you are filling the dropdown from the database and want a certain record selected based on a value passed you would do something like this
Code:
cProject = Trim(CInt(Request.QueryString("Project")))

Response.write("<select name='Project'>")
do until rs.eof
   If IsNull(cProject) OR Len(cProject) = 0 Then
      Response.write("<option value=" & rs("ProjectValue") & ">" & rs("ProjectName") & "</option">
   Else
      If cProject = Trim(CInt(rs("ProjectValue"))) Then
         Response.write("<option value=" & rs("ProjectValue") & " Selected>" & rs("ProjectName") & "</option>")
      Else
         Response.write("<option value=" & rs("ProjectValue") & ">" & rs("ProjectName") & "</option">
      End If
   End If
   rs.movenext
loop
Response.write("</select>")

Reply With Quote
  #5  
Old May 18th, 2004, 10:27 AM
cptCaveman cptCaveman is offline
Registered User
ASP Free Newbie (0 - 499 posts)
 
Join Date: May 2004
Posts: 3 cptCaveman User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Thanks for your help Memnoch.

Page is working just as it's supposed to now. The line:

Trim(CInt())

was the clincher. I'd actually been trying to find stuff on
casting but had little success.

Again, my thanks for your help, it is much appreciated.

Reply With Quote
Reply

Viewing: ASP Free ForumsOtherProgramming Help > When 'If' stops working ...


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 4 hosted by Hostway