Home > Archive > ASP > June 2005 > Combo box value
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
|
|
|
| Hi,
Question, I use often a combo box on my ASP pages.
each time a form is submitted, the value of the combo box returns to the
first selection
But is there a way to avoid this and show always your latest selection ?
Thx in advance
TNG
| |
| Bob Barrows [MVP] 2005-06-11, 3:55 pm |
| TNG wrote:
> Hi,
>
> Question, I use often a combo box on my ASP pages.
> each time a form is submitted, the value of the combo box returns to
> the first selection
> But is there a way to avoid this and show always your latest
> selection ?
> Thx in advance
>
Here's one way:
<%
dim selection, options
selection=request.form("cmb")
options="<option value='a'>A</option><option value='b'>" & _
"B</option><option value='c'>C</option>"
if len(selection) > 0 then
options = replace(options,"value='" & selection & "'", _
"value='" & selection & "' selected")
end if
%>
<html>
<body>
<form method="post">
<select name="cmb">
<%=options%>
</select>
<input type="submit">
</form></body></html>
HTH,
Bob Barrows
--
Microsoft MVP - ASP/ASP.NET
Please reply to the newsgroup. This email account is my spam trap so I
don't check it very often. If you must reply off-line, then remove the
"NO SPAM"
|
|
|
|
|