1. js选中多个checkbox,取值向后台提交数据
<html> <head> <script type="text/javascript" src="jquery-1.8.3.js"></script> <script> $(function() { $("#delete").click(function() { //页面弹框 if(!confirm("确定要删除吗?")) { window.event.returnValue = false; } //调用函数 del(); }); }); function del(){ //1.过滤出被选中的 var checkedList = $('input:checkbox').filter(":checked"); if (checkedList.length == 0) { alert("未选中记录!"); return false; } var ids = ""; checkedList.each(function(){ ids += $(this).val()+","; }); ids = ids.substring(0,ids.length-1); //向后台发送数据 window.location.href = "/search/my_delete?data="+ids; } </script> </head> <body> one:<input type="checkbox" value="one"/><br/> two:<input type="checkbox" value="two"/><br/> three:<input type="checkbox" value="three"/><br/> four:<input type="checkbox" value="four"/><br/> <input type="button" id="delete" value="删除"/> </body> </html>