how to select a default value of combo box in run time

S

sangram

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...

advance thanks..
 
A

ASM

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.value == val) combo.options.selected = true;
}

defCombo(document.myForm.combobox, 'something');
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,582
Members
45,065
Latest member
OrderGreenAcreCBD

Latest Threads

Top