zoukankan      html  css  js  c++  java
  • layer父页获取弹出层输入框里面的值

    主要是因为修改功能,原来页面填写数据如图

    改为

    其中点击填写明细弹出框

    填写完毕后点击确认返回,同事这里因为她是存的多表,所以点击确认就直接保存数据了,改的这个功能原本保存是整体保存,我就不想改原来的逻辑,只想把填写的值带回去用隐藏控件存一下,到时候按照原来的逻辑整体存,所以没办法参考她的,最后搜索很多,解决了问题,具体代码如下:

    父页面:

    <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>

  • 相关阅读:
    python3 numpy基本用法归纳总结
    MySQL 中的三中循环 while loop repeat 的基本用法
    什么是网关及网关作用
    网络扫描工具nmap
    nmap基本使用方法
    nmap脚本使用总结
    用Delphi将数据导入到Excel并控制Excel
    delphi Form属性设置 设置可实现窗体无最大化,并且不能拖大拖小(写一个WM_EXITSIZEMOVE的空函数)
    Delphi 数据类型列表
    一个队列类的实现(比delphi自带的速度快70倍)(线程安全版本)
  • 原文地址:https://www.cnblogs.com/fkcxy/p/9253846.html
Copyright © 2011-2022 走看看