sangram a écrit :
how to select a default value of combo box in run time,
i have select some value from database ,depending on this i have to set
the value of combox box...
<option selected value=" ...
on the fly :
<form name="myForm" ... >
<select name="combobox">
<option ...
<option ...
<option value="something"... <-- will be selected and send on submit
<option ...
<option ...
</select>
document.myForm.combobox.options[2].selected = true;
With a loop on values :
function defCombo(combo, val) {
for(var i=0; i<combo.length; i++)
if(combo.options[i].value == val) combo.options[i].selected = true;
}
defCombo(document.myForm.combobox, 'something');
--
ASM