vivcode
04-13-2005, 01:54 AM
I saw there were many sample codes to display dynamic drop down but there were none sample that pre-selected values when the drop down list was displayed.
Once the drop down is displayed, users can select multiple values from the drop down and the selected values are saved to the database. The next time the drop down is displayed, I want to pre-select values that users already selected and saved before.
The problem is it only pre-select the last value. For example,
obj.options[2].selected = true;
obj.options[3].selected = true;
and it display the drop down with only the 3rd value pre-selected as opposed to both 2nd and 3rd values.
However, if I put any alert() statement in there, it worked fine. That is weird.
obj.options[2].selected = true;
alert(obj.multiple); <== result is true
alert(obj.type); <== result is select-one
obj.options[3].selected = true;
Does it have to do with the drop down being out of focus or the type is select-one? How do I set the type to select-multiple? I tried obj.type="select-multiple" and it didn't like that.
Please help. Thank you.
Once the drop down is displayed, users can select multiple values from the drop down and the selected values are saved to the database. The next time the drop down is displayed, I want to pre-select values that users already selected and saved before.
The problem is it only pre-select the last value. For example,
obj.options[2].selected = true;
obj.options[3].selected = true;
and it display the drop down with only the 3rd value pre-selected as opposed to both 2nd and 3rd values.
However, if I put any alert() statement in there, it worked fine. That is weird.
obj.options[2].selected = true;
alert(obj.multiple); <== result is true
alert(obj.type); <== result is select-one
obj.options[3].selected = true;
Does it have to do with the drop down being out of focus or the type is select-one? How do I set the type to select-multiple? I tried obj.type="select-multiple" and it didn't like that.
Please help. Thank you.