Here's some simple script that will highlight ALL
options and with a few modifications, you can make it
so it selects only the ones you wish, either by hard-coding it,
or by creating an array of values, splitting it and checking if the
current option is in the list of options to be selected, while looping
through your options collection on the dropdown element.
==============================
<form name="test">
<select name="mySelect" multiple size="4">
<option value="1">1
<option value="2">2
<option value="3">3
<option value="4">4
</select>
<input type="button" onclick="selectMultiple()" value="Select 'Em">
</form>
<Script language='Javascript'>
<!--
function selectMultiple(){
var objForm = document.forms['test']
var objEl = objForm.elements['mySelect']
for(var x = 0; x < objEl.options.length; x++){
objEl.options[x].selected = true
}
alert(objEl.options.length)
}
// -->
</script>
==============================
Hope that helps,
Chris Tifer
----- Original Message -----
From: "Nicolas Verhaeghe" <[EMAIL PROTECTED]>
To: "ActiveServerPages" <[EMAIL PROTECTED]>
Sent: Monday, October 14, 2002 9:40 AM
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]