PDA

View Full Version : ASP <select> lists - Can they remember your choice ?


Brad
09-06-2002, 04:30 PM
Hi,

Whenever I select an option from a set of <select><option> values, and submit it to the same form, the option I choose disappears, and the list is reset to the values at the top of the list.

Eg.

A drop down list has the values 1,2,3,4,5 in it. I choose number 4, submit that using a submit button. The data I want to display based on that choice is displayed, but the list returns to it's original value, ie. '1'.

Is there any way to make the list remember the value i chose, as it looks confusing to have the 'incorrect' info at the top, in the selection box.

Hope this makes sense.

Thanks in advance,
Brad.

allida77
09-06-2002, 06:12 PM
stick this after your form:
<script>
Response.Write("document.forms[0].sltTskType.value=" & Request.Form("sltBoxValueName") & ";" )
</script>

whammy
09-07-2002, 11:28 PM
<select name="test">
<option value="1"<% If test = "1" Then Response.Write(" selected=""selected""") %>>1</option>
<option value="2"<% If test = "2" Then Response.Write(" selected=""selected""") %>>2</option>
<option value="3"<% If test = "3" Then Response.Write(" selected=""selected""") %>>3</option>
<option value="4"<% If test = "4" Then Response.Write(" selected=""selected""") %>>4</option>
<option value="5"<% If test = "5" Then Response.Write(" selected=""selected""") %>>5</option>
</select>