doujiene2845 2010-12-19 09:37
浏览 105

将JS中的数组发送到php

I'm trying to do something similar to this question. I want to send to the server the id's of the selected checkboxes. I'm using jquery only because the example. my ajax code is pure JS.

This is my code:

js:

function DeleteTest(ind)
 {
   if (confirm('Are you sure you want to delete this test?'))
      {
    ​   $(function() {
       var testdel = $('input[name=deletetest]').serialize();
       alert(testdel);
       window.open('test.php' + "?"+testdel,'_self');
           }   ​);
        return true;}
         else { return false;}
 }
  oCell.innerHTML = "<input type='checkbox' name='deletetest' value='"+ ind +   "')';>"; // create checkbox for each row in ajax

html:

<form id="checkboxform" action="test.php" method="post">
<tbody id="auditTblBody">
</tbody>
</table>
<input type="button" value="Submit AJAX Request" onclick="DeleteTest()" />
</form>

With this code i get only one value with GET.testdel is fine. (i.e deletetest=477&deletetest=476) my problem is how to send this information.

thank you!

  • 写回答

2条回答 默认 最新

  • dsavz66262 2010-12-19 09:42
    关注

    For PHP to recognize multiple values from inputs with the same name, that name must end in the characters [].

      oCell.innerHTML = "<input type='checkbox' name='deletetest[]' value='"+ ind +   "')';>"; 
    
    评论

报告相同问题?

悬赏问题

  • ¥15 基于单片机的靶位控制系统
  • ¥15 AT89C51控制8位八段数码管显示时钟。
  • ¥15 真我手机蓝牙传输进度消息被关闭了,怎么打开?(关键词-消息通知)
  • ¥15 下图接收小电路,谁知道原理
  • ¥15 装 pytorch 的时候出了好多问题,遇到这种情况怎么处理?
  • ¥20 IOS游览器某宝手机网页版自动立即购买JavaScript脚本
  • ¥15 手机接入宽带网线,如何释放宽带全部速度
  • ¥30 关于#r语言#的问题:如何对R语言中mfgarch包中构建的garch-midas模型进行样本内长期波动率预测和样本外长期波动率预测
  • ¥15 ETLCloud 处理json多层级问题
  • ¥15 matlab中使用gurobi时报错