form提交表格加表单数据

表格数据

 <input type="hidden" name="materialFieldModel">
                  <label class="layui-form-label" style=" width: 110px;padding: 9px 9px;">物质-场模型</label>
                  <div class="layui-input-block">
                    <table class="layui-table">
                      <colgroup>
                        <col width="15%">
                        <col width="15%">
                        <col width="15%">
                        <col width="15%">
                        <col width="15%">
                        <col width="15%">
                        <col width="10%">
                      </colgroup>
                      <thead>
                        <tr>
                          <th>功能主体(S2)</th>
                          <th>功能主体(S1)</th>
                          <th>作用类型</th>
                          <th></th>
                          <th>场类型</th>
                          <th>符号</th>
                          <th>操作</th>
                          <th><button type="button" class=" addcenter layui-btn" onclick="fieldModel()"
                              style="float:right;">
                              <i class="layui-icon"></i>添加
                            </button></th>
                        </tr>
                      </thead>
                      <tbody id="modelTbody">
                      </tbody>
                    </table>

提交

//提交
  form.on('submit(normSolutionCreate)', function (data) {
    let arrayList = new Array();
    $("#modelTbody tr").each(function (index, element) {
      let tdList = $(element).children();
      let insertNorm = {};
      insertNorm.funcMain = tdList.eq(0).find("input").val();
      insertNorm.funcGuest = tdList.eq(1).find("input").val();
      insertNorm.actionType = tdList.eq(2).find("input").val();
      insertNorm.fieldName = tdList.eq(3).text();
      insertNorm.fieldType = $("#modelTbody tr:eq(" + index + ") select:eq(0) option:selected").text();
      insertNorm.symbol = tdList.eq(5).text();
      if (insertNorm.funcMain == "" || insertNorm.funcGuest == "" || insertNorm.fieldName == "" || insertNorm.fieldType == "请选择") {
        layer.msg("请填写(选择)参数!");
        return false;
      }
      arrayList[index] = insertNorm;
    })
    // debugger;
    data.field.materialFieldModel = JSON.stringify(arrayList);
    $.ajax({
      url: "insertNormSolution",
      method: 'post',
      data: data.field,
      dataType: "json",
      success: function (res) {
        if (res.code == 0) {
          layer.msg(res.tipMsg, {
            icon: 1,
            anim: 6,
            time: 3600
          });
          setTimeout(function () {
            window.location.href = "standSolution";
          },
            1800);
        } else {
          layer.msg("提交失败!");
        }
      }
    });
    return false; //这里很重要,一定要加这个。要不然提交后弹出层会刷新一次,从而不执行ajax的success
  })
  • 1
    点赞
  • 5
    收藏
    觉得还不错? 一键收藏
  • 2
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值