Hello Javascript Users,
I recently started doing some stuff in javascript again but now i am running into some problems which i can't find a solution to.
I have two select boxes in a form the values of the second select box are populated with specific values based on the selection made in the first select box ( this completely works ).
function UpdateMethodField( sel ){
var secondsel = document.getElementById('id_method');
var selvalue = sel.options[sel.selectedIndex].value;
var count = secondOptions[ selvalue ].length;
secondsel.options.length = 0;
for( i =0; i<count; i++)
secondsel.options = new Option( secondOptions[selvalue][0],secondOptions[selvalue][1] );
}
secondOptions is the array holding the values to each specific value in the first select box.
The problem is when i populate the second select box i also want to give along the selected="selected" value. i thought i could do this with the following code.
secondsel.selectedIndex="199";
But this won't work. however it gives some reaction because the select box will give a complete empty field with no index. I checked if this value was in the array and it is so that is not the problem.
Does anyone know how to solve this.
any help would be greatly appreciated,
thank in advance.
Richard
I recently started doing some stuff in javascript again but now i am running into some problems which i can't find a solution to.
I have two select boxes in a form the values of the second select box are populated with specific values based on the selection made in the first select box ( this completely works ).
function UpdateMethodField( sel ){
var secondsel = document.getElementById('id_method');
var selvalue = sel.options[sel.selectedIndex].value;
var count = secondOptions[ selvalue ].length;
secondsel.options.length = 0;
for( i =0; i<count; i++)
secondsel.options = new Option( secondOptions[selvalue][0],secondOptions[selvalue][1] );
}
secondOptions is the array holding the values to each specific value in the first select box.
The problem is when i populate the second select box i also want to give along the selected="selected" value. i thought i could do this with the following code.
secondsel.selectedIndex="199";
But this won't work. however it gives some reaction because the select box will give a complete empty field with no index. I checked if this value was in the array and it is so that is not the problem.
Does anyone know how to solve this.
any help would be greatly appreciated,
thank in advance.
Richard