Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ios/96.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
Javascript 是否可以根据后端php脚本中的批动态分配这些复选框的名称?_Javascript_Php_Html - Fatal编程技术网

Javascript 是否可以根据后端php脚本中的批动态分配这些复选框的名称?

Javascript 是否可以根据后端php脚本中的批动态分配这些复选框的名称?,javascript,php,html,Javascript,Php,Html,批次1 中心1 中心2 center3 <input type="checkbox" name=center$a[] value="3"> center4 <input type="checkbox" name=center$a[] value="4"><br> batch2 <br> center1 <input type="che

批次1

中心1 中心2

            center3    <input type="checkbox" name=center$a[] value="3">

            center4    <input type="checkbox" name=center$a[] value="4"><br>

      batch2  <br>
              center1   <input type="checkbox" name=center$a[] value="1">
             center2    <input type="checkbox" name=center$a[] value="2">

             center3    <input type="checkbox" name=center$a[] value="3">

             center4   <input type="checkbox" name=center$a[] value="4"><br>

 batch3       <br>

             center1   <input type="checkbox" name=center$a[] value="1">
             center2   <input type="checkbox" name=center$a[] value="2">

              center3  <input type="checkbox" name=center$a[] value="3">

             center4   <input type="checkbox" name=center$a[] value="4"><br>

   batch4    <br>


           center1     <input type="checkbox" name=center$a[] value="1">
             center2   <input type="checkbox" name=center$a[] value="2">

             center3   <input type="checkbox" name=center$a[] value="3">

             center4   <input type="checkbox" name=center$a[] value="4"><br>

    <input type="submit" name="submit">
        Is it possible to assign names of these checkboxes dynamically according to the batch in the back end php script?
center3
中心4
批次2
中心1 中心2 中心3 中心4
批次3
中心1 中心2 中心3 中心4
批次4
中心1 中心2 中心3 中心4
是否可以根据后端php脚本中的批动态分配这些复选框的名称?

我尝试在名称中使用变量,但在后端php脚本中接收值时,它不会单独使用变量,因此我无法根据批分配动态值

可能是因为没有计算变量,请尝试更改以下行:

<input type="checkbox" name="center<?= $a ?>" value="1">

当然,您必须在每个批次中更改
$a
变量。

如果他希望所有复选框都在一个数组中,那么应该是
如果应该有四组(“批次”)的“中心”变量,那么您是对的,只要他在每个批次中更改
$a
变量。
<input type="checkbox" name="center<?= $a ?>[]" value="1">