Skip to content Skip to sidebar Skip to footer

Mapping Json List Of Selectlistitems To Dropdown Select List With Jquery And Indicating Selected Item

I have a JSON list of SelectListItems that I grab: new SelectListItem { Text = item.Name, Value = item.Id.ToStr

Solution 1:

function (data) {
    data= $.map(data, function (item, a) {
    return "<option value=" + item.Value + " " + (item.Selected ? "selected": "") + ">" + item.Text + "</option>";
          });

    $("#edit-user-list").html(data.join(""));

Post a Comment for "Mapping Json List Of Selectlistitems To Dropdown Select List With Jquery And Indicating Selected Item"