Hi all, i have already populate a list from my database using the following code <form method=post action="ProcessOrder.asp"> <select NAME="TEST"> <% Do while NOT rsHis.EOF response.write "<OPTION VALUE=' " & rshis("pic_id") & " '> " response.write rshis("title") rsHis.MoveNext loop %> </select> Code (markup): But i dont know how to present the results from the combo box...any sample code would much appreciated
i'm a little confused - what are you askind specifically? your code looks like it should work fine as far as building the combo box etc...
I think you've got confused near your quotes... double quotes ("") represent single quotes (") inside the <% a= "xyz" %> asp script tags... where you see 3 in a row - that means that it's quote ("") and end string (") try this: <select> <% Do while NOT rsHis.EOF response.write "<OPTION VALUE=""" & rshis("pic_id") & """>" response.write rshis("title") & "</OPTION>" rsHis.MoveNext loop %> </select> Code (markup): I've also closed the option tag, that's just good practice
both suggestions are good - but i'm still confused as to what he was asking, because the option tag should have worked with apostrophes instead of quotes even though it's better practice to do it your way, and as you said the closing of the option tag is optional - /methinks this may be yet another one of those mysterious random users that shows up and posts a relatively obfuscated question and never comes back... leaving us to ponder... what does it all mean? hmmm....
hi all again... i am not mysterious random user...just had a job to finish and i didnt have time to respond...sorry for that... in my question now... sorry if i confuse you... my english is not very well... Well i am trtying to say is that although... the above script works fine I dont know how can I show the results of this code to the page i set it (ProcessOrder.asp)...what kind of code should i use???... One more question... i would like to see not only the pic_id from the database but and a title (description) next to it...is it possible and how??? thank you
lets give an example...from a combo box i select an item and would return me a number (pic_id)...lets say 10... i dont want to see only the number 10 but also a title/description of that...lets say "the number you choose is:" 10
ok, for that, you would do something like: pic_id - request.form("pic_id") response.write "the number you choose is: " & pic_id you would also need to name your select element on the form page - i.e. <select name = "pic_id" > <% Do while NOT rsHis.EOF response.write "<OPTION VALUE=""" & rshis("pic_id") & """>" response.write rshis("title") & "</OPTION>" rsHis.MoveNext loop %> </select>
You can't return the label from a select box so you'll have to do another query if you want to write it back to the page... If a user submits the form - and you want to remember selection? <select name = "pic_id" > <% Do while NOT rsHis.EOF response.write "<OPTION VALUE=""" & rshis("pic_id") & "" " If CInt(request.form("pic_id")) = rshis("pic_id") Then response.write "SELECTED" End If response.write ">" response.write rshis("title") & "</OPTION>" rsHis.MoveNext loop %> </select> that should do it?