Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/282.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 检查框列的Post表行_Php_Forms_Html Table - Fatal编程技术网

Php 检查框列的Post表行

Php 检查框列的Post表行,php,forms,html-table,Php,Forms,Html Table,我有一张这样的桌子 <form method="post" action="url"> <table> <tr> <td><input type="checkbox" name="cbox[]" value="1"></td> <td><input type="text" name="name[]" value="first_name"></td> </tr>

我有一张这样的桌子

<form method="post" action="url">
<table>
 <tr>
  <td><input type="checkbox" name="cbox[]" value="1"></td>
  <td><input type="text" name="name[]" value="first_name"></td>
 </tr>

 <tr>
  <td><input type="checkbox" name="cbox[]" value="2"></td>
  <td><input type="text" name="name[]" value="second_name"></td>
 </tr>

 <tr>
  <td><input type="checkbox" name="cbox[]" value="3"></td>
  <td><input type="text" name="name[]" value="third_name"></td>
 </tr>
</table>
<input type="submit" value="send" />
</form>

然后,当我发布此表单时,我只想发送选中复选框的行的
cbox[]
name[]

将html更改为

      <form id ='myform' method="post" action="url">
        <input type='hidden' id='checkboxs' name='checkboxs'>
        <input type='hidden' id='names' name='names'>
        <table>
         <tr>
          <td><input type="checkbox" name="cbox[]" value="1"></td>
          <td><input type="text" name="name1" value="first_name"></td>
         </tr>

         <tr>
          <td><input type="checkbox" name="cbox[]" value="2"></td>
          <td><input type="text" name="name2" value="second_name"></td>
         </tr>

         <tr>
          <td><input type="checkbox" name="cbox[]" value="3"></td>
          <td><input type="text" name="name3" value="third_name"></td>
         </tr>
        </table>
        <input type="button" value="send" onclick="submitValue()"/>
    </form>
您在复选框和名称中的值
希望通过PHP提交此帮助

?您可以将操作附加为PHP或使用Ajax解析信息。如果有尝试和错误,请与他人分享?
        function submitValue()
        {
            var checkboxs = [];
            var names = [];
            $(':checkbox:checked').each(function(i){
               checkboxs[i] = $(this).val();
               names[i] = $('input[name=name'+(i+1)+']').val();
            });
            console.log(checkboxs);
            console.log(names);
            $('#checkboxs').val(checkboxs);
            $('#names').val(names);
            $('#myform').submit();
        }