Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/240.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

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/security/4.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 传递一个按数字递增的变量_Php_Ajax - Fatal编程技术网

Php 传递一个按数字递增的变量

Php 传递一个按数字递增的变量,php,ajax,Php,Ajax,我有一个变量,当我选择人数时它会增加,所以我想通过ajax将这个变量传递到另一个页面 我的代码如下: for(var i = 1; i <= num; i++) { container.append('<tr><th width="120"><div align="left">Person on Room "'+i+'"</div></th><td><input type="text" name="txtHo

我有一个变量,当我选择人数时它会增加,所以我想通过ajax将这个变量传递到另一个页面

我的代码如下:

for(var i = 1; i <= num; i++) {
  container.append('<tr><th width="120"><div align="left">Person on Room "'+i+'"</div></th><td><input type="text" name="txtHotelCustomerNameSingle'+i+'[]" id="txtHotelCustomerNameSingle'+i+'" size="15" placeholder="Single Room"></td></tr>');
}

我认为
Array
是一个更好的解决方案

var txtHotelCustomerNameSingle = new Array();
for (...)
{
    txtHotelCustomerNameSingle[i] = ...
}

或者您可以只执行
var txtHotelCustomerNameSingle=[];对于(…
ok,但是如何区分此
和此
在输入中使用相同的名称,并且当您的表单将发送数据时,它将作为数组发送输入(使用相同的名称)
var txtHotelCustomerNameSingle = new Array();
for (...)
{
    txtHotelCustomerNameSingle[i] = ...
}