JS
var index = layer.open({
title: '编辑用户',//编辑
type: 2,
shade: 0.2,
maxmin: true,
shadeClose: true,
area: ['100%', '100%'],
content: 'AdUserDetailsEdit.aspx',
success: function (layero, index) {
//从父页面向子页面传值
var body = layer.getChildFrame('body', index);
var iframeWin = layero.find('iframe')[0].contentWindow;
//获取子页面的元素,进行数据渲染
body.contents().find("#UID").val(data["UID"]);
body.find("input[name=Gender][value=0]").attr("checked", data["Gender"] == "0" ? true : false);
body.find("input[name=Gender][value=1]").attr("checked", data["Gender"] == "1" ? true : false);
body.find("input[name=Gender][value=2]").attr("checked", data["Gender"] == "2" ? true : false);
body.contents().find('#Tel').val(data["Tel"]);
var province = 'dd[lay-value=' + data["province"] + ']';
var city = 'dd[lay-value=' + data["city"] + ']';
var area = 'dd[lay-value=' + data["area"] + ']';
//模拟点击选择数据
body.find('#province').siblings("div.layui-form-select").find('dl').find(province).click();
body.find('#city').siblings("div.layui-form-select").find('dl').find(city).click();
body.find('#area').siblings("div.layui-form-select").find('dl').find(area).click();
//回显数据(不可少)
iframeWin.layui.form.render();
}
});
html
<div class="layui-form-item" id="area-picker">
<label class="layui-form-label">居住地区</label>
<div class="layui-input-inline" style="width: 100px;">
<select name="province" class="province-selector" id="province" data-value="" lay-filter="province-1">
<option value="">请选择省</option>
</select>
</div>
<div class="layui-input-inline" style="width: 100px;">
<select name="city" class="city-selector" id="city" data-value="" lay-filter="city-1">
<option value="">请选择市</option>
</select>
</div>
<div class="layui-input-inline" style="width: 100px;">
<select name="area" class="county-selector" id="area" data-value="" lay-filter="county-1">
<option value="">请选择区</option>
</select>
</div>
</div>
这里的area原本是country