LayUI中实现上级下拉框动态加载下级下拉框js

js代码:

var form = layui.form, layer = layui.layer;
form.on("select(上级)", function(data){
	var url = Const.apiUrl + "获取下级下拉框集合的Url";
	View.get(url, "khlx=" + data.value, function(resp) {
		$("select[name='下级']").html("");
		var html = "<option value>--属性名称--</option>";
		for (var i = 0; i < resp.length; i++) {
			html += "<option value = '" + resp[i].key +"'>" + resp[i].value +"</option>";
		}
		$("select[name='下级']").append(html);
		// 刷新select选择框渲染
		form.render();
	}, function() {
		TmplUtils.showMsgFail(Locale.get("custRiskRateConfig.info.propFail"));
	});
});

   参考:https://jingyan.baidu.com/article/afd8f4deafd30634e386e950.html

posted @ 2018-10-11 14:08  ヤBig、Bossづ  阅读(964)  评论(0编辑  收藏  举报