layer父页获取弹出层输入框里面的值方法
程序员文章站
2022-09-07 08:38:31
主要是因为修改功能,原来页面填写数据如图
改为
其中点击填写明细弹出框
填写完毕后点击确认返回,同事这里因为她是存的多表,所以点击确认就直接保存数据了,改...
主要是因为修改功能,原来页面填写数据如图
改为
其中点击填写明细弹出框
填写完毕后点击确认返回,同事这里因为她是存的多表,所以点击确认就直接保存数据了,改的这个功能原本保存是整体保存,我就不想改原来的逻辑,只想把填写的值带回去用隐藏控件存一下,到时候按照原来的逻辑整体存,所以没办法参考她的,最后搜索很多,解决了问题,具体代码如下:
父页面:
<div class="row"> <div class="col-md-6"> <div class="form-group padtb10"> <label class="labelw150"> 经费来源总计(元)</label> <input type="text" readonly="readonly" class="form-control" id="amountsum" name="amountsum" onkeyup="value=value.replace(/[^\d.]/g,'')" placeholder="填写来源明细" value="@pro.amountsum"/> <input type="button" value="填写来源明细" onclick="showamountdetail()" /> <input type="hidden" name="centeramount" id="centeramount" value="@pro.centeramount" /> <input type="hidden" name="cityamount" id="cityamount" value="@pro.cityamount" /> <input type="hidden" name="disamount" id="disamount" value="@pro.disamount" /> <input type="hidden" name="streetamount" id="streetamount" value="@pro.streetamount" /> <input type="hidden" name="otheramount" id="otheramount" value="@pro.otheramount" /> </div> </div> </div>
js:
//弹出经费来源明细 function showamountdetail() { var index = layer.open({ type: 2, title: '填写经费明细', shadeclose: false, skin: 'layui-layer-rim', area: ['50%', '50%'], maxmin: true, content: '/project/amountdetail?projectcode=' + "@projectcode", btn: ['确定', '关闭'], yes: function (index, layero) { debugger; var body = layer.getchildframe('body', index); //得到iframe页的body内容 var centeramount = body.find("#centeramount").val(); var cityamount = body.find("#cityamount").val(); var disamount = body.find("#disamount").val(); var streetamount = body.find("#streetamount").val(); var otheramount = body.find("#otheramount").val(); if (centeramount == null || centeramount == "") centeramount = 0; if (cityamount == null || cityamount == "") cityamount = 0; if (disamount == null || disamount == "") disamount = 0; if (streetamount == null || streetamount == "") streetamount = 0; if (otheramount == null || otheramount == "") otheramount = 0; sum = number(centeramount) + number(cityamount) + number(disamount) + number(streetamount) + number(otheramount); document.getelementbyid("centeramount").value = centeramount; document.getelementbyid("cityamount").value = cityamount; document.getelementbyid("disamount").value = disamount; document.getelementbyid("streetamount").value = streetamount; document.getelementbyid("otheramount").value = otheramount; document.getelementbyid("amountsum").value = sum; //最后关闭弹出层 layer.close(index); }, cancel: function () { //右上角关闭回调 } }); // layer.full(index); }
子页面:
<!doctype html> <html> <head> <meta name="viewport" content="width=device-width" /> <title>amountdetail</title> </head> <body> <div> <table class="table table-bordered "> <tr><td rowspan="5" style="text-align: center; vertical-align: middle;">经济来源明细</td><td>*拨款(元)</td> <td> <input id="centeramount" class="form-control" onkeyup="value=value.replace(/[^\d.]/g,'')" name="centeramount" type="text" /> </td></tr> <tr><td>市级专款(元)</td> <td> <input id="cityamount" class="form-control" onkeyup="value=value.replace(/[^\d.]/g,'')" name="cityamount" type="text" /> </td></tr> <tr><td>区级资金(元)</td> <td> <input id="disamount" class="form-control" onkeyup="value=value.replace(/[^\d.]/g,'')" name="disamount" type="text" /> </td></tr> <tr><td>街镇配套(元)</td> <td> <input id="streetamount" class="form-control" onkeyup="value=value.replace(/[^\d.]/g,'')" name="streetamount" type="text" "/> </td></tr> <tr><td>其他(元)</td> <td> <input id="otheramount" class="form-control" onkeyup="value=value.replace(/[^\d.]/g,'')" name="otheramount" type="text" /> </td></tr> </table> </div> </body> </html>
以上这篇layer父页获取弹出层输入框里面的值方法就是小编分享给大家的全部内容了,希望能给大家一个参考,也希望大家多多支持。
上一篇: layui中的switch开关实现方法
下一篇: vue路由教程之静态路由