I've been using the following to display the statename in my dropdown:

$('#State option[value="' + LocationObject.State + '"]').attr('selected',
'selected');                      

LocationObject is a json object that I am using. The problem with this is
that it does not add 'selected' to the option tage of the dropdown so when
the user submits the form the value of the dropdown is incorrect. How can I
add 'selected' to the option. Seems easy but I've not foind a solution to
this in any posts.

btw: I've also tried these 2 without luck either:

$("#State").val(LocationObject.State).attr('selected', 'selected');
$("#State").val(LocationObject.State);

thanks!
-- 
View this message in context: 
http://old.nabble.com/How-to-add-%27selected%27-to-option-of-dynamically-set-Select-input--tp27394631s27240p27394631.html
Sent from the jQuery General Discussion mailing list archive at Nabble.com.

Reply via email to