weixin_33696106 2015-02-19 12:09 采纳率: 0%
浏览 33

集体数据和jQuery

You can usually use something like this:

<form action="example.php" method="POST">
<input type="text" name="file_name[]">
<input type="text" name="file_name[]">
<input type="text" name="file_name[]">

to collect data under the same name, and access it in PHP like:

$file_name = $_POST["file_name"];
echo $file_name[0]; //first occurrence
echo $file_name[2]; //third occurrence

but when it comes to generating dynamic fields with jQuery, like this:

$("#example_table").append("<tr><td><input type="text" name="file_name[]"></td></tr>");

and submitting it with standard submit button within POST form, the outcome differs. Only the last occurrence gets passed but the array indexes represent consecutive letters of such, not exact, indicated field as above.

The question is, why and how to fix it?

  • 写回答

3条回答 默认 最新

  • weixin_33671935 2015-02-19 12:13
    关注

    You can use single quote instead of double quote for file_name. Might be this is useful to you.

    $("#example_table").append("<tr><td><input type='text' name='file_name[]'></td></tr>");
    
    评论

报告相同问题?

悬赏问题

  • ¥15 请问GPT语言模型怎么训练?
  • ¥15 已知平面坐标系(非直角坐标系)内三个点的坐标,反求两坐标轴的夹角
  • ¥15 webots有问题,无响应
  • ¥15 数据量少可以用MK趋势分析吗
  • ¥15 使用VH6501干扰RTR位,CANoe上显示的错误帧不足32个就进入bus off快慢恢复,为什么?
  • ¥15 大智慧怎么编写一个选股程序
  • ¥100 python 调用 cgps 命令获取 实时位置信息
  • ¥15 两台交换机分别是trunk接口和access接口为何无法通信,通信过程是如何?
  • ¥15 C语言使用vscode编码错误
  • ¥15 用KSV5转成本时,如何不生成那笔中间凭证