html页面如:
<form name="formName" method="post">
<input type="checkbox" name="id" value="1">
<input type="checkbox" name="id" value="2">
<input type="checkbox" name="id" value="3">
<input type="checkbox" name="id" value="4">
<input type="checkbox" name="id" value="5">
<input type="button" value="删 除" onclick="delete()">
</form>
这个页面要进行批量删除所选中的id数据,并且要用ajax功能在本页面实现无刷新功能。
我想到用ajax的post方式,但不知如何传一个id数组进行执行,请大家帮忙解决,谢谢!

解决方案 »

  1.   

    能传对象么??
    不太清楚!但是可以用for循环便利一下用字符串连接来传
    在后台用split截取下就好了
      

  2.   

    不用传数组,把要删除的id值用逗号连接,然后用delete.jsp?delId=1,2,3,4..的形式传给servlet或Action。
    这样做的目的是使用sql的delete table where id in (1,2,3,4),也就是in关键字的应用。
      

  3.   

    把你的id值传给你的ajax执行,不需要post
      

  4.   

    1.
    delete是保留字, 不能用
    2.
    <form name="formName" method="post"> 
    <input type="checkbox" name="id" value="1"> 
    <input type="checkbox" name="id" value="2"> 
    <input type="checkbox" name="id" value="3"> 
    <input type="checkbox" name="id" value="4"> 
    <input type="checkbox" name="id" value="5"> 
    <input type="button" value="删 除" onclick="javascript:fn()"> 
    </form> 
    <script>
    function fn(){
    var arr=document.getElementsByName("id");
    var ids="";
    for (var i=0; i<arr.length; i++){
    if (arr[i].checked){
    ids=ids+","+arr[i].value;
    }
    }
    ids=ids.substring(1);
    alert(ids);
    }
    </script>
      

  5.   

    先用js 判断 那些checkbox 是选中的,吧选中的id用 ","拼接。作为一个字符串。后台split(",")
    分割。
      

  6.   

    到ajax的论坛问
    回答的答案不是跟好
      

  7.   

    先把选定的ID取出来,边接成一个字符串通过url一弁传过去.
    如果你用jQury的话,可以用ajaxSubmit()方法,再去转去url取值..
      

  8.   

    这样的东西还是post好  感觉
    做asp很注意防什么狗屁东西了