Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Javascript > how to select a default value of combo box in run time

Reply
Thread Tools

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

 
 
sangram
Guest
Posts: n/a
 
      10-25-2006
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..

 
Reply With Quote
 
 
 
 
ASM
Guest
Posts: n/a
 
      10-25-2006
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
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Re: How include a large array? Edward A. Falk C Programming 1 04-04-2013 08:07 PM
How to reference one combo box from another combo box SM Javascript 2 04-28-2007 04:49 PM
Default value for combo box Doogie ASP General 11 02-26-2007 02:49 PM
Fill Combo Box based on another Combo Box dthmtlgod ASP General 1 11-16-2005 04:08 PM
select of select box will select multiple in another box palmiere Javascript 1 02-09-2004 01:11 PM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57