layui——父页面获取layer.open弹窗中的值
1、获取input中的值
content页面
<div style="padding: 0 10px;margin-top:10px"> <input type="text" id="refuseReason" name="refuseReason" placeholder="请输入拒绝理由" class="layui-input"> </div>
父页面
layer.open({ type:1, title:"拒绝理由", content:'<div style="padding: 0 10px;margin-top:10px">'+ '<input type="text" id="refuseReason" name="refuseReason" placeholder="请输入拒绝理由" class="layui-input">'+ '</div>', area: ['500px', '150px'], btn: ['提交', '取消'], btnAlign:'c', resize:true, yes:(index,layero)=>{ // 获取content页面中id为refuseReason的值 const refuseReason = top.$('#refuseReason').val(); }, cancel:(index, layero)=>{} })
2、获取select中选中的值
content页面
<select id="groupId" name="groupId" xm-select="group"> <span th:each="info : ${groupList}"> <option th:text="${info.st_g_name}" th:value="${info.st_g_id}"></option> </span> </select>
父页面
layer.open({ type: 2, title: "标题", area: ['600px', '500px'], content: "/page/layerOpen", //请求后端返回页面地址 btn: ['提交', '取消'], yes: function(index, layero){ //得到iframe页的窗口对象,执行iframe页的方法: var iframeWin = window[layero.find('iframe')[0]['name']]; // 获取页面中xm-select属性为group的下拉选择框选中的值 var selectGroupData = iframeWin.layui.formSelects.value('group', 'val'); console.log(selectGroupData); } })
3、