[thelist] forms
Rory.Plaire at wahchang.com
Rory.Plaire at wahchang.com
Mon Jul 9 13:07:24 CDT 2001
|
| What is the best way in JavaScript to get highlighted options
| from one form
| or one select box and transmit them, those highlighted
| choices, to another
| select box or textarea. Just give me some ideas and commands.
|
Hi Adam,
I am having to experiment with this very thing. My draft solution has the
browser doing this little dance...
<watch forwhat="text wrap">
...
function copyVal(selObj1, selObj2)
{ if(ie4up){
var newOpt = document.createElement("OPTION");
newOpt.text = selObj1.options[selObj1.selectedIndex].text;
newOpt.value = selObj1.options[selObj1.selectedIndex].value;
selObj2.options.add(newOpt, selObj1.selectedIndex);
}
if(nn4up){
selObj2.options[selObj2.length] = new Option(selObj1.text,
selObj1.value, false, false);
//meaning new Option(Option Text, Option Value, default?,
selected?)
}
...
<select name="select" size="12" onclick="copyVal(select, select2)">
<option value="red">red</option>
<option value="ora">ora</option>
<option value="yel">yel</option>
<option value="grn">grn</option>
<option value="blu">blu</option>
<option value="idg">idg</option>
<option value="vlt">vlt</option>
</select>
<select name="select2" size="12">
</select>
</watch>
<rory disposition="too tired from watching Finding Forrester last night, but
happy!" alt="|)"/>
More information about the thelist
mailing list