Forum Moderators: open

Message Too Old, No Replies

Help with combobox

How to set an item selected in combo?

         

Riab

6:39 pm on Feb 29, 2004 (gmt 0)

10+ Year Member



I've a combo box in my form with the name of all days like "MON","TUE",... I need to set the day selected with respect to the value of an hidden field called 'day_sel'.
Suppose
day_sel="TUE", i need TUE to be set selected in combo. Is there any method for combo in javascript like setSelectedItem or setText? Plz reply with the argument that is to be passed with that method

Purple Martin

11:53 pm on Feb 29, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



You don't use a method, you set a property.

Firstly, loop through all the option objects and set their selected property to false. Then set the one you want to true.

Syntax info at this reference site:

[devguru.com...]