PDA

View Full Version : is there way to create MULTIPLE options


umen
08-17-2002, 05:23 PM
Hello
what im trying to do is that :
i have 2 select boxes . i like to be able to chose multiply options (witch or curse i can with MULTIPLE )
but i like to past all of the chosen options to the second box in one click.
i only know the standard way to move only one option every time .
is it can be done?
tnx

beetle
08-17-2002, 11:30 PM
you need to loop through all the options of the SELECT object and test to see if each one is selected. Something like this....

<script>
function copySelections(oSelect1, oSelect2) {
for (var i in oSelect1)
if (oSelect1.options[i].selected)
oSelect2.options[i].selected = true;
}
</script>

<input type="button" value="Copy" onClick="copySelections(this.form.select1, this.form.select2);" Of course, this assumes that you want to copy the selections over based on their index. And, as you can see, the way this function is setup, it could very easily be switched to copy from 2 to 1. If you actually want to dynamically add OPTION objects to select2, then you should be able to insert your code into this function.

RadarBob
08-18-2002, 03:50 AM
Here's a link to a thread that includes code that does what you need.

http://www.codingforums.com/showthread.php?s=&threadid=675