error in adding to dropdown using jquery

Posted by Klbaiju under jQuery on 8/13/2013 | Points: 10 | Views : 2367 | Status : [Member] | Replies : 3
Hi,

I want to add values in dropdownlist using jquery

following code is working

$("#drpdriver").append($("<option></option>").val(value.driverid).html(value.drivername));

my requrement is add "select a category" at the beginning of dropdown

how to solve this

Regards

Baiju




Responses

Posted by: Bandi on: 8/13/2013 [Member] [MVP] Platinum | Points: 25

Up
0
Down
Refer this link
http://stackoverflow.com/questions/7997209/how-do-i-add-an-option-to-a-dropdown-list-using-jquery

Alternate solution is to use .prepend() method...
http://stackoverflow.com/questions/7346268/add-option-to-select-menu-at-the-beginning-of-the-menu?lq=1
http://api.jquery.com/prepend/

Mark This Response as Answer
--
Chandu
http://www.dotnetfunda.com/images/dnfmvp.gif

Klbaiju, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Macki on: 8/13/2013 [Member] Starter | Points: 25

Up
0
Down


Hi,

Here u go if u add the value in code behind itself
http://stackoverflow.com/questions/12135091/jquery-take-value-and-insert-into-dropdown-menu-and-add-url-as-option-value

and Check this
http://stackoverflow.com/questions/8141669/adding-an-item-to-drop-down-list-with-jquery-at-a-certain-index

Regards
Macki

Klbaiju, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Macki on: 8/13/2013 [Member] Starter | Points: 25

Up
0
Down


Hi..

Check This Link..
http://forums.asp.net/t/1652538.aspx/1

Regards
Macki

Klbaiju, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response