To set the value for the select you can just use jQuery's
val function. However, to have it work with a
reset button you need to set the
selected attribute within the HTML.
- function fillDeclineReasonList(selectedValue) {
- $.getJSON('<%=
ResolveUrl("~/myurl/")%>', function (data) {
- ReasonCollections = data;
- var items = "";
- items += "<option value=''>Select One</option>";
- $.each(data, function (i, ReasonCollections) {
- items
+= "<option value='" + ReasonCollections.Value + "'" +
- (ReasonCollections.Value == selectedValue ? " selected" : "") + ">" +
- ReasonCollections.Text + "</option>";
- });
- items += "<option value='Others'>Others</option>";
- $("#declinereasons").html(items);
- });
- }