html 删除
<input type="checkbox" id="id" name="id"/>js获取值
// 获取勾选的复选框 function getCheckboxList() { var strIds = ""; $('input[name=id]:checked').each(function(){ strIds += $(this).val() + ","; }); if(strIds.length > 0) { strIds = strIds.substring(0, strIds.length - 1); } return strIds; } function doAsyncBatchDelete() { if ( confirm("确认要删除?") ) { var strIds = getCheckboxList("selectedRow"); if(strIds.length > 0) { $.ajax({ type: "post", url: root + "/test/deleteAsync", data :{ "strIds" : strIds }, cache: false, async:false, dataType: "json", success: function(data){ if(data.success) { window.parent.frames[ "mainFrame"].location.reload(true); } else { alert(data.msg); } } }); } else { alert("请勾选需要删除的数据!"); } } }Action 对接获取参数的方法
public void deleteAsync() throws SysException { HttpServletRequest request = getHttpServletRequest(); String[] strIds = request.getParameterValues("strIds"); if(strIds != null && strIds.length > 0) { // 1. 校验该角色是否被使用,如果被使用,给出提示不能删除 try { // 2. 做你的删除操作 } catch (Exception e) { e.printStackTrace(); } } }