|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
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
|
|||
|
|||
|
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 |
|
#2
|
|||
|
|||
|
sorry, my kowledge on listboxes isnt that good.
|
|
#3
|
|||
|
|||
|
can you explain the problem more specifically and the error massage you are getting may be i can help you
|
|
#4
|
|||
|
|||
|
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? |
|
#5
|
||||
|
||||
|
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. |
|
#6
|
|||
|
|||
|
No that is the code! I mean the code of the list box, which is what I am concerned about
|
|
#7
|
|||
|
|||
|
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! |
![]() |
| Viewing: Dev Shed Forums > Programming Languages - More > ASP Programming > listBox |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|