<bdo id='hbQ6c'></bdo><ul id='hbQ6c'></ul>

  • <i id='hbQ6c'><tr id='hbQ6c'><dt id='hbQ6c'><q id='hbQ6c'><span id='hbQ6c'><b id='hbQ6c'><form id='hbQ6c'><ins id='hbQ6c'></ins><ul id='hbQ6c'></ul><sub id='hbQ6c'></sub></form><legend id='hbQ6c'></legend><bdo id='hbQ6c'><pre id='hbQ6c'><center id='hbQ6c'></center></pre></bdo></b><th id='hbQ6c'></th></span></q></dt></tr></i><div id='hbQ6c'><tfoot id='hbQ6c'></tfoot><dl id='hbQ6c'><fieldset id='hbQ6c'></fieldset></dl></div>

    <small id='hbQ6c'></small><noframes id='hbQ6c'>

    <tfoot id='hbQ6c'></tfoot>
        <legend id='hbQ6c'><style id='hbQ6c'><dir id='hbQ6c'><q id='hbQ6c'></q></dir></style></legend>

        layui复选框如何向后台传值接值

        时间:2024-07-18

          <bdo id='h2ldA'></bdo><ul id='h2ldA'></ul>
        • <small id='h2ldA'></small><noframes id='h2ldA'>

            <tbody id='h2ldA'></tbody>

          1. <legend id='h2ldA'><style id='h2ldA'><dir id='h2ldA'><q id='h2ldA'></q></dir></style></legend>

              <tfoot id='h2ldA'></tfoot>
                  <i id='h2ldA'><tr id='h2ldA'><dt id='h2ldA'><q id='h2ldA'><span id='h2ldA'><b id='h2ldA'><form id='h2ldA'><ins id='h2ldA'></ins><ul id='h2ldA'></ul><sub id='h2ldA'></sub></form><legend id='h2ldA'></legend><bdo id='h2ldA'><pre id='h2ldA'><center id='h2ldA'></center></pre></bdo></b><th id='h2ldA'></th></span></q></dt></tr></i><div id='h2ldA'><tfoot id='h2ldA'></tfoot><dl id='h2ldA'><fieldset id='h2ldA'></fieldset></dl></div>
                  使用layui复选框的时候需要向后台传递值,值的形式为逗号分割的形式。如下图需要选择多个条件。

                  layui的前端样式代码如下:
                        <div class="layui-form-item">
                          <label class="layui-form-label">复选框</label>
                          <div class="layui-input-block">
                              <input type="checkbox" name="level"   value="1" title="一级">
                              <input type="checkbox" name="level"   value="2" title="二级">
                              <input type="checkbox" name="level"   value="3" title="三级">
                              <input type="checkbox" name="level"   value="4" title="四级">
                              <input type="checkbox" name="level"   value="5" title="五级">
                          </div>
                      </div>
                  
                  向后台传值JS代码,通过ajax向后台传递参数即可:
                  layui.use(['form'], function () {
                  
                      var form = layui.form;
                      var $ = layui.jquery
                  
                      //监听提交
                      form.on('submit(form)', function (data) {
                  
                          if ($("input:checkbox[name='level']:checked").length == 0) {
                              return;
                          }
                          //获取checkbox[name='level']的值,获取所有选中的复选框,并将其值放入数组中
                          var arr = new Array();
                          $("input:checkbox[name='level']:checked").each(function(i){
                              arr[i] = $(this).val();
                          });
                          //  替换 data.field.level的数据为拼接后的字符串
                          data.field.level = arr.join(",");//将数组合并成字符串
                  
                  
                          layer.confirm('是否保存?', {
                              btn: ['确定', '取消'] //按钮
                          }, function () {
                              $.post("modify"
                                  , data.field
                                  , function (res) {
                                      if (res.success == true) {
                                          parent.layer.close(index);
                                      }
                                  }
                              )
                          }, function () {
                              parent.layer.close(index);
                          });
                  
                      });
                      return false;
                  });
                  
                   
                  上一篇:layui实现弹窗下拉搜索选择框功能 下一篇:没有了

                  相关文章

                      <bdo id='MhuCK'></bdo><ul id='MhuCK'></ul>
                  1. <tfoot id='MhuCK'></tfoot>

                      <small id='MhuCK'></small><noframes id='MhuCK'>

                    1. <legend id='MhuCK'><style id='MhuCK'><dir id='MhuCK'><q id='MhuCK'></q></dir></style></legend>
                      <i id='MhuCK'><tr id='MhuCK'><dt id='MhuCK'><q id='MhuCK'><span id='MhuCK'><b id='MhuCK'><form id='MhuCK'><ins id='MhuCK'></ins><ul id='MhuCK'></ul><sub id='MhuCK'></sub></form><legend id='MhuCK'></legend><bdo id='MhuCK'><pre id='MhuCK'><center id='MhuCK'></center></pre></bdo></b><th id='MhuCK'></th></span></q></dt></tr></i><div id='MhuCK'><tfoot id='MhuCK'></tfoot><dl id='MhuCK'><fieldset id='MhuCK'></fieldset></dl></div>