Reputation: 631
I need to set the this as a default value for my list box can any body help me out.
thanks
$(document).ready(function () {
var targetid = '<%:ViewData["target"] %>';
if (targetid != null) {
$("#lstCodelist").val(targetid); //// I need to set this targetid as default selected value for lstCodelist
}
Upvotes: 2
Views: 5236
Reputation: 114377
Set n to the index of the item you wish to set as selected.
$("#lstCodelist option").eq(n).attr('selected','selected')
Upvotes: 3