Click to See Complete Forum and Search --> : auto-selecting multiple select values upon submit


GoldDog
05-10-2003, 06:55 PM
I have a situation (don't we all?) in which I am moving the contents of one multiple select to another. This works great. But when I submit the form, the contents of the second are not recognized. This is because they are not 'selected' when the form is submitted. They have to be manually selected for the action template to recognize their existence, but as everyone surely knows, clients (those pesky people who pay our bills) don't think this is terribly intuitive. So my situation (yes, I still have one) is that I need to dynamically select the contents of this second multiple select when the form is submitted.

Surely a simple exercise in javascript, but since I don't actually think in this language, I'm not sure how to go about it. About as far as I can get is that it needs to be an onSubmit event.

Thanks for any suggestions.

khalidali63
05-10-2003, 08:26 PM
Presuming that you want to select all of the option values in the list box,and the form name is "form1" listbox name is "lb_2"
here is the javascript that will select all of the options, just call this function before you submit.

function Process(){
var listBox = document.form1.lb_2;
var len = listBox.length;
for(var x=0;x<len;x++){
listBox.options[x].selected= true;
}
}

GoldDog
05-10-2003, 08:58 PM
That was the answer. Thanks Khalid.

khalidali63
05-10-2003, 09:00 PM
You are welcome ..:D