1、动态改变控件
由银行 --> 代收公司
<select id="ddlLevel" name="ddlLevel" class="input-medium"> <option value="">@Html.Lang("Font_quanbu") </option> </select> <script> //绑定等级 function funBindLevel() { $("#ddlLevel").empty(); var type = parseInt($("#ddlType").val()); var i = 0; if (type !== 0) { $("#spWithdraw").hide(); } else { $("#spWithdraw").show(); } if (type === 0 || type === 3) { //银行 common.Ajax({ url: "../LoadData/BanksOutStatistic.ashx", data: { "action": "getBank", "type": type } }, function (msg) { var jsonBank = eval(msg); $("#ddlLevel").append("<option value=\"-1\">" + jsonCode["Font_yinhang"] + "</option>"); for (i = 0; i < jsonBank.length; i++) { $("#ddlLevel").append("<option value=\"" + jsonBank[i].f_bankName + "\">" + jsonBank[i].f_bankName + "</option>"); } //使用bootstrap-select渲染 $("#ddlLevel").attr("class", "selectpicker input-large ddlLevel"); $("#ddlLevel").attr("data-live-search", "true"); $("#ddlLevel").attr("data-style", "btn-white"); $("#ddlLevel").attr("data-size", 10); $("#ddlLevel").attr("data-width", 165); $('#ddlLevel').selectpicker('refresh'); //渲染最后要刷新一下 }); } else if (type === 1) { $('.selectpicker').selectpicker('destroy');//以编程方式销毁bootstrap-select //支付宝 $("#ddlLevel").append("<option value=\"-1\">" + jsonCode["Font_dengjizhangben"] + "</option>"); for (i = 0; i < 5; i++) { $("#ddlLevel").append("<option value=\"" + i + "\">" + funGetLevelShow(i) + "</option>"); } $("#ddlLevel").append("<option value=\"5\">" + jsonCode["Font_qtzb"] + "</option>"); } else if (type === 2) { //代付 common.Ajax({ url: "@Url.Action("GetYeePayType")" }, function (msg) { var dafaryJson = eval("(" + msg + ")"); $("#ddlLevel").append("<option value=\"-1\">" + jsonCode["Font_dsgs"] + "</option>"); for (i = 0; i < dafaryJson.length; i++) { $("#ddlLevel").append("<option value=\"" + dafaryJson[i].f_type + "\">" + dafaryJson[i].f_name + "</option>"); } //使用bootstrap-select渲染 $("#ddlLevel").attr("class", "selectpicker input-large ddlLevel"); $("#ddlLevel").attr("data-live-search", "true"); $("#ddlLevel").attr("data-style", "btn-white"); $("#ddlLevel").attr("data-size", 10); $('#ddlLevel').selectpicker('refresh'); }); } } </script>