今天用到另一款jq插件..插件就是无脑,,引入相关文件,开始撸吧
引入相关文件:
<link href="~/Scripts/combo-select/combo.select.css" rel="stylesheet" /> <script src="~/Scripts/combo-select/jquery.combo.select.js"></script>
html/js
1 <td style="position:relative; top:8px;"> 2 @Html.DropDownList("mechanism", ViewData["hospital"] as IEnumerable<SelectListItem>, new { @class = "keyword",style="width:220px;" }) 3 </td>
1 $('select').comboSelect(); 2 3$('select').change(function (e, v) { 4 param.HosCode = e.target.value; 5});
将选中值传到后台 ,完了~~
异步加载下拉框
1 $.ajax({ 2 type: "Get", 3 url: '/WithdrawApply/LoadMemInfo', 4 dataType: "json", 5 cache: false, 6 async: false, 7 success: function (json) { 8 var data = eval(json);//json数组 9 10 var optionStr = ''; 11 for (var i = 0; i < data.length; i++) { 12 optionStr += "<option value=\"" + data[i].SearchCode + "\" >" 13 + data[i].MechanismName + "</option>"; 14 } 15 16 $("#mechanism").append(optionStr); 17 } 18 });
19 $('select').comboSelect();
参考: http://www.dowebok.com/179.html
http://blog.csdn.net/qq_15241071/article/details/78424162
http://blog.csdn.net/ly210501076/article/details/47313365