You can try something like this.
<select name="myVar" multiple size="3">
<option value="1" <% If Request.Form("MyVar") = "1" Then %>SELECTED<% End If
%>>Choice 1</option>
<option value="2" <% If Request.Form("MyVar") = "2" Then %>SELECTED<% End If
%>>Choice 2</option>
<option value="3" <% If Request.Form("MyVar") = "3" Then %>SELECTED<% End If
%>>Choice 3</option>
<option value="4" <% If Request.Form("MyVar") = "4" Then %>SELECTED<% End If
%>>Choice 4</option>
<option value="5" <% If Request.Form("MyVar") = "5" Then %>SELECTED<% End If
%>>Choice 5</option>
</select>
You'll need to alter the logic slightly to account for splitting the
variable by the comma or just do an InStr() test depending on what exactly
the value really is.
-----Original Message-----
From: Nicolas Verhaeghe [mailto:[EMAIL PROTECTED]]
Sent: Monday, October 14, 2002 12:40 PM
To: ActiveServerPages
Subject: Reselecting all selected choices in a multiple <select>
This is more an HTML question, but some of you might have the answer.
I protect my forms client-side and also server-side.
By client-side I mean a javascript checking for most of the forgotten
information, and server-side a more complex information verification
routine which displays the form again in case of an error, and with
error messages on top.
The form shows the information which was previously entered, including
selecting the correct choices in my <select> inputs.
In case of a multiple select, what I do is split the response string for
that variable, as multiple choices are returned in a comma-separated
string of multiple values.
My problem is that only the first element in the array will be selected:
<select name="myVar" multiple size="3">
<option value="1" selected>Choice 1
<option value="2">Choice 2
<option value="3" selected>Choice 3
<option value="4">Choice 4
<option value="5" selected>Choice 5
</select>
This should hightlight Choice 1, 3 and 5. But it does not ... Only
Choice 1 is highlighted, while Request("myVar") was equal to "1, 3, 5".
How can one preselect multiple choices in a <select ... Multiple ... >
drop-down?
---
You are currently subscribed to activeserverpages as:
[EMAIL PROTECTED]
To unsubscribe send a blank email to
%%email.unsub%%
---
You are currently subscribed to activeserverpages as: [email protected]
To unsubscribe send a blank email to [EMAIL PROTECTED]