划红框的部分是主要部分,进行参数的传递。 父页面: !DOCTYPE htmlhtml lang="en" xmlns:th="http://www.thymeleaf.org"head/headbodyinput type="text" name="projectno" autocomplete="off"id="projectno" placeholder="项目编号" class="layui-input"input type="text" name="requestid" autocomplete

划红框的部分是主要部分,进行参数的传递。
父页面:
<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head>
</head>
<body>
<input type="text" name="projectno" autocomplete="off"id="projectno" placeholder="项目编号" class="layui-input">
<input type="text" name="requestid" autocomplete="off"placeholder="经责项目立项表requestid" class="layui-input" id="requestid">
<script>
let earequestid = $('#requestid').val();
let eaprojectno = $('#projectno').val(); //获取input框中的值
layer.open({
type: 2,
title: title,
shade: 0.1,
area: ['500px', '500px'],
content: openFormWord,
success: function (layero, index) {
var body = layer.getChildFrame('body', index);
//'layer.getChildFrame()'方法为Layui内置方法。
//当你试图在当前页获取iframe页的DOM元素时,你可以用此方法(在当前页获取iframe页的DOM元素)
body.find('form').find('#economicApprovalRequestid').val(earequestid);
//'#economicApprovalRequestid',这个参数是写的子页面的input框的id值;
//后面的.val(earequestid)是获取父页面(也就是这个页面)的值后,进行赋值给子页面id为'economicApprovalRequestid'的input框。
body.find('form').find('#projectNum').val(eaprojectno);
}
});
</script>
</body>
</html>
主要点:layer.getChildFrame()方法:为Layui内置方法。在当前页获取iframe页的DOM元素
body.find(‘form’).find(’#economicApprovalRequestid’).val(earequestid):’#economicApprovalRequestid’,这个参数是写的子页面的input框的id值;后面的.val(earequestid)是获取父页面(也就是这个页面)的值后,进行赋值给子页面id为’economicApprovalRequestid’的input框。
编程基础网
本文标题为:layer.open父页面传参到子页面
基础教程推荐
猜你喜欢
- 【vue】三种获取input值的写法 2023-10-08
- html网页中使用希腊字母的方法 2022-09-21
- JavaScript函数this指向问题详解 2023-08-12
- JavaScript开发简单易懂的Svelte实现原理详解 2023-08-12
- Ajax实现简单下拉选项效果【推荐】 2022-12-28
- 使用HTML5中postMessage知识点解决Ajax中POST跨域问题 2022-10-17
- ajax异步加载图片实例分析 2022-12-18
- vue在install时node-sass@4.14.1 postinstall:node scripts/build.js错误解决 2023-07-09
- Ajax实现关键字联想和自动补全功能及遇到坑 2023-02-23
- AJAX实现数据的增删改查操作详解【java后台】 2023-02-23
