javascript - How do I set a dropdown option by value using jquery? -
i have fiddle has slight demo code: http://jsfiddle.net/mwoods98/mhrjj/
i have request being sent via ajax , it's returning values via json. that, i'm taking returned , filling in form. i'm filling in form other values can't quite figure out how set dropdown value returned.
$('#postitle').find('option:eq(posvar)').val().prop('selected', true);
i have tired , doesn't work. posvar variable i'm setting number returned ajax.
update: both of answers, have discovered something.
i'm using code make drop downs better need drop down can have multimple lines of html.
http://www.marghoobsuleman.com/jquery-image-dropdown
when remove js, form fills in.
i'm open using library gives me ability use multiple rows in select dropdown , pass html it.
thanks answers.
Comments
Post a Comment