Click to See Complete Forum and Search --> : Selecting the item in the dropdown list..
jeba
Oct 12th, 2000, 02:27 AM
Hi there!
I want to select (or highlight) the item in a listbox while sending back the data to the browser, which the user has selected in the listbox before sending to the server. I am able to send back all the data to the appropriate controls except the listbox (for validation purpose). Please help me.
Either Javascript or vbscript code is ok. (and ofcourse it is a asp page)
monte96
Oct 12th, 2000, 09:59 AM
I'm confused. HTML Listboxes behave this way by default, there is nothing to do to get it to do what you are asking...
jeba
Oct 12th, 2000, 11:58 PM
Hi there!
I wanted to do server side validation. After requesting the data from the client, I am checking the data from the serverside and sending the data back to the client if any error found, so that the user may change it and re-send. But I don't know how to select or highlight the value (which the user has selected before sending to the server) of the listbox through code.
monte96
Oct 13th, 2000, 09:40 AM
Use a HTML form to pass the data back to your page and put code at the beginning of your page that checks for the form data. If it's found process it, otherwise simply display the page as normal.
<HTML>
<BODY>
<FORM id=MyForm method=post action="MyPage.asp">
<SELECT id=MySelect>
<OPTION value=BLAH1>BLAH 1 BLAH</OPTION>
<OPTION value=BLAH2>BLAH 2 BLAH</OPTION>
</SELECT>
<INPUT type=Submit id=MySubmit value=Submit>
</FORM>
</BODY>
</HTML>
At the top of your page:
<%
If Request.Form("MySelect").Count > 0 Then
'{Do Something with the data here}
End If
%>
If you'd like to have the value still highlighted when the page is reloaded you can check the value in request.form against the value you are writing into the select tag (Presumably from a database) and add a 'selected' attribute if it is equal.
vbforums.com
Copyright Internet.com Inc., All Rights Reserved.