c# - Data not displayed in jQuery multiselect plugin -
i'm trying populate drop-down using jquery multiselect plugin. when use simple drop-downs have hard coded value, works properly. however, when fetch records database populate drop-down, records not displayed in drop-down in ie (it works fine in chrome).
javascript
<script> function fill(u, f, d, c) { $.ajax({ type: "post", url: u + '/' + f, data: d, contenttype: "application/json; charset=utf-8", datatype: "json", async: false, cache: false, success: function (r) { var i; //$('#' + c + '').length = 0; var myitem = r.d.split('#'); $('#' + c + '').empty(); (i = 0; < myitem.length; = + 2) { $('#' + c).append(new option('' + myitem[i + 1] + '','' + myitem[i] + '')); } } }); } $(document).ready(function () { fill('webform1.aspx', 'filldepartmentdropdown', '{}', 'ddldepartment'); $("#ddldepartment").multiselect({ header: "choose department!" }); }); </script>
cs
[webmethod] public static string filldepartmentdropdown() { string dataoutput = ""; dataset ds; hashtable objparameters = new hashtable(); businesslogiclayer objbusiness = new businesslogiclayer(); ds = objbusiness.spdataset(objparameters, "selectalldept"); (int = 0; < ds.tables[0].rows.count; i++) { datarow dr = ds.tables[0].rows[i]; dataoutput = dataoutput + "#" + dr["department"].tostring() + "#" + dr["id"].tostring(); } return dataoutput; }
html
<select id="ddldepartment" ><option>32</option> <option>3213</option><option>321</option></select>
the issue because new option
works bad on ie, try change how append to: '<option value="' + myitem[i + 1] + '">' + myitem[i + 1] + '</option>'
Comments
Post a Comment