PDA

View Full Version : Multiple options......


JonGretar
03-21-2001, 08:29 PM
I have a slight problem. Really a newbie stuff.
I'm trying to create a <SELECT> where you can select multiple OPTION's and then all of the values selected are automatically inserted into a text box.
So if you select Option1, Option2 and Option4 from the list then the value of a textbox would be like "Option1;Option2;Option4"

However I am having a hard time finding ALL the highlited selected items. I can just get the value of the item you selected last. How do I get all of them???

kdjoergensen
03-22-2001, 04:53 PM
var selTxt="";
var selObj = document.formName.selectObjectName;

for (var j=0;j<selObj.length;j++){
if (selObj.options[j].selected){
selTxt += selObj.options[j].text+";"
}
}
document.formName.textElement.value = selTxt;

Try it..
Kenneth

JonGretar
03-22-2001, 05:03 PM
Thanks

Works fine

kdjoergensen
03-22-2001, 05:04 PM
Hwew... (*sigh of relief*) :D