layui——父页面获取layer.open弹窗中的值

1、获取input中的值

content页面

1
2
3
<div style="padding: 0 10px;margin-top:10px">
    <input type="text" id="refuseReason" name="refuseReason" placeholder="请输入拒绝理由" class="layui-input">
</div>

  

父页面

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
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页面

1
2
3
4
5
  <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>

  

父页面

1
2
3
4
5
6
7
8
9
10
11
12
13
14
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、

作者:假装空白
欢迎任何形式的转载,但请务必注明出处。
限于本人水平,如果文章和代码有表述不当之处,还请不吝赐教。

posted @   假装空白  阅读(1617)  评论(0编辑  收藏  举报
相关博文:
阅读排行:
· 无需6万激活码!GitHub神秘组织3小时极速复刻Manus,手把手教你使用OpenManus搭建本
· C#/.NET/.NET Core优秀项目和框架2025年2月简报
· Manus爆火,是硬核还是营销?
· 终于写完轮子一部分:tcp代理 了,记录一下
· 【杭电多校比赛记录】2025“钉耙编程”中国大学生算法设计春季联赛(1)
点击右上角即可分享
微信分享提示