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数组进行执行,请大家帮忙解决,谢谢!
<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数组进行执行,请大家帮忙解决,谢谢!
不太清楚!但是可以用for循环便利一下用字符串连接来传
在后台用split截取下就好了
这样做的目的是使用sql的delete table where id in (1,2,3,4),也就是in关键字的应用。
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>
分割。
回答的答案不是跟好
如果你用jQury的话,可以用ajaxSubmit()方法,再去转去url取值..
做asp很注意防什么狗屁东西了