ASP Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsProgramming Languages - MoreASP Programming

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 Dev Shed Forums Sponsor:
Get inside! Sample the range of functionality easily built with JMSL Library for Time Series Data Analysis, Heat Maps, Portfolio Optimization, Monte Carlo Simulation, Stock Price Charting and more. Download Now!
  #1  
Old July 15th, 2003, 03:56 AM
monfu monfu is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Apr 2003
Location: Dublin
Posts: 40 monfu User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 31 m 25 sec
Reputation Power: 6
listBox

Dear all, I have a problem with a list box. I am populating a list box from a table in an MS ACCESS database and display the results, which I am managing to do. However, when the user clicks an option, I wish this option to be selected from the menu, in its appropriate order, and not as the first item. At the moment I am doing this:-

-----------------------------------------------------------------------------------
Dim RsTier1,RsTier1ID

Set RsTier1 = Server.CreateObject ("ADODB.Recordset")
RsTier1.ActiveConnection = cnn

RsTier1.Open ("SELECT * FROM Tier1 Order by Tier1Tit ASC")
if not RsTier1.EOF or not RsTier1.BOF then
RsTier1.MoveFirst
if Tier1ID <> 0 then
Set RsTier1ID = Server.CreateObject ("ADODB.Recordset")
RsTier1ID.ActiveConnection = cnn
RsTier1ID.Open ("SELECT * FROM Tier1 where Tier1ID=" & Tier1ID)
If Not RsTier1ID.Eof or Not RsTier1.Bof then
Tier1Tit = RsTier1ID("Tier1Tit")
While Not RsTier1.Eof
if RsTier1.Fields("Tier1ID") = Tier1ID then
Response.Write ("<OPTION SELECTED VALUE=""" & Tier1ID & """>" & (Tier1Tit) & "</OPTION>")
else
Response.Write ("<OPTION VALUE=""" & RsTier1.Fields("Tier1ID") & """>" & (RsTier1.Fields("Tier1Tit")) & "</OPTION>")
end if
RsTier1.MoveNext
Wend
Response.Write ("<OPTION VALUE=""0"">no main section</OPTION>")
end if
else
Response.Write ("<OPTION VALUE=""0"">no main section</OPTION>")
While Not RsTier1.Eof
Response.Write ("<OPTION VALUE=""" & RsTier1.Fields("Tier1ID") & """>" & (RsTier1.Fields("Tier1Tit")) & "</OPTION>")
RsTier1.MoveNext
Wend
end if
else
Response.Write ("<OPTION VALUE=""0"">no sub section</OPTION>")
end if

-------------------------------------------------------------------------------

I am getting Tier1ID from a request.Form("Tier1ID").

The problem seems to be in this line of code:-

------------------------------------------------------------------
if RsTier1.Fields("Tier1ID") = Tier1ID then
------------------------------------------------------------------

Should I change it to Number after getting it from the request.Form? If yes how?

Can anyone help me out cause I cannot manage to solve it!

Thanks for your help and time

Reply With Quote
  #2  
Old July 15th, 2003, 04:19 AM
Agarash Agarash is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Apr 2003
Location: South Africa
Posts: 53 Agarash User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 7 m 35 sec
Reputation Power: 6
sorry, my kowledge on listboxes isnt that good.

Reply With Quote
  #3  
Old July 15th, 2003, 04:39 AM
rgdubey rgdubey is offline
I am here to share knowledge
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Apr 2003
Location: India
Posts: 83 rgdubey User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 6
can you explain the problem more specifically and the error massage you are getting may be i can help you

Reply With Quote
  #4  
Old July 15th, 2003, 04:52 AM
monfu monfu is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Apr 2003
Location: Dublin
Posts: 40 monfu User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 31 m 25 sec
Reputation Power: 6
Well the error that I am getting is that the selected item of the list box after I press the submit button, is always the first Item in the list box and not the one I have selected, since the ID I am passing from the form is not matching the ID in the table.

Is that ok?

Reply With Quote
  #5  
Old July 15th, 2003, 06:33 AM
kkong's Avatar
kkong kkong is offline
Monkey Magic
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Sep 2002
Location: UK
Posts: 103 kkong User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 6
Send a message via ICQ to kkong
Hi monfu,

If I understand correctly, you are saying that you have a form with a drop down box and you are not getting the value you want?

If that's the case then can we see that code, I think you have shown us the results of what the form does after the submit?

Kong.

Reply With Quote
  #6  
Old July 15th, 2003, 06:44 AM
monfu monfu is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Apr 2003
Location: Dublin
Posts: 40 monfu User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 31 m 25 sec
Reputation Power: 6
No that is the code! I mean the code of the list box, which is what I am concerned about

Reply With Quote
  #7  
Old July 15th, 2003, 07:04 AM
monfu monfu is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Apr 2003
Location: Dublin
Posts: 40 monfu User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 31 m 25 sec
Reputation Power: 6
ok I solved it, the problem was what I thought, had to change the field in the database to string to compare with request.form

Thanks!

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming Languages - MoreASP Programming > listBox


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 1 hosted by Hostway