"Alexandre Laplante" <al*******@avior.ca> writes:
Is this possible in javascript to modify the OPTION of an SELECT from an
other one..? So the first selection change the second option list.
Yes.
You can trigger on the change to the first select element using the
onchange event handler. You can then change the contents of the second
select element from this handler.
To change all the options of a select element (here referenced by
selectRef), you can do something like
var newOptions = ["option1","value1","option2","value2"];
var optsRef = selectRef.options;
while (optsRef.length > 0) { // Delete the current options
selectRef.remove(optsRef[0]);
}
for (var i=0;i< newOptions.length;i+=2) {
selectRef.add(new Option(newOptions[i],newOptions[i+1]),null);
}
That is, use "selectRef.remove" to remove an option and
"selectRef.add(new Option(text,value),null)" to add a new option.
/L
--
Lasse Reichstein Nielsen -
lr*@hotpop.com
Art D'HTML: <URL:http://www.infimum.dk/HTML/randomArtSplit.html>
'Faith without judgement merely degrades the spirit divine.'