views:

87

answers:

3

how to set or change value to drop down.

I'm having a drop down list which is initially not selected a value.

How can i select a value using jquery

+5  A: 

The val() function is used to get and set the value of input controls (including <select>). Grab a jQuery reference to your <select>, and pass its val() function a string matching the value attribute of the <option> that you wish to select:

$("#mySelect").val("15");

This would select the second option in this list:

<select id="mySelect">
    <option value="5">Few</option>
    <option value="15">More</option>
    <option value="100">Many</option>
</select>
Jørn Schou-Rode
A: 
$("#id_select").val("value_1");

id_select -> is the id of your select

value_1 -> is one of the values presents in the option of select

tommaso
A: 

To set the drop down value as selected then it may help you. http://praveenbattula.blogspot.com/2009/08/jquery-how-to-set-value-in-drop-down-as.html

Rare Solutions