这是我的Action:
public ActionForward delete(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response) {
String id = request.getParameter("acqid");
acquisitionService.delete(Integer.parseInt(id));
return this.getfAll(mapping, form, request, response);
}
------------------------------------------------------------------------------
这是我的Jsp页面:
<logic:iterate id="acq" name="acquisitionf">
<tr>
<td>
<input type="checkbox" name="acqid" value=${acq.id } >
</td>
<td>${acq.id}</td>
<td>${acq.createtime}</td>
<td>${acq.manager }</td>
<td>${acq.userNo}</td>
<td>${acq.scrapDoc }</td>
<td>${acq.scrapClear }</td>
</tr>
</logic:iterate>
<A href="viewAcquisition.do?method=delete&acqid=${acq.id }">删除</A>
--------------------------------------------------------------------------------问题是:
我现在可以做删除的功能
但是我删除的都是下一个
比如
序列号 姓名 地址
复选框 1 小小 北京
复选框 2 三三 上海
意思就是当我删除的时候永远先删除 序列号为 2 的数据
而且复选框的功能不知道怎么做 ?(复选框选不选 我都能删除)
public ActionForward delete(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response) {
String id = request.getParameter("acqid");
acquisitionService.delete(Integer.parseInt(id));
return this.getfAll(mapping, form, request, response);
}
------------------------------------------------------------------------------
这是我的Jsp页面:
<logic:iterate id="acq" name="acquisitionf">
<tr>
<td>
<input type="checkbox" name="acqid" value=${acq.id } >
</td>
<td>${acq.id}</td>
<td>${acq.createtime}</td>
<td>${acq.manager }</td>
<td>${acq.userNo}</td>
<td>${acq.scrapDoc }</td>
<td>${acq.scrapClear }</td>
</tr>
</logic:iterate>
<A href="viewAcquisition.do?method=delete&acqid=${acq.id }">删除</A>
--------------------------------------------------------------------------------问题是:
我现在可以做删除的功能
但是我删除的都是下一个
比如
序列号 姓名 地址
复选框 1 小小 北京
复选框 2 三三 上海
意思就是当我删除的时候永远先删除 序列号为 2 的数据
而且复选框的功能不知道怎么做 ?(复选框选不选 我都能删除)
放到页面循环标签内,这样才能每行记录对应一个唯一ID.
这种我可以删除啊 但是我现在不是实现这一的功能 就是页面查询出来
然后点击复选框checkBox 删除该删除的数据
删除的按钮是放在下面的
var a = document.getElementsByName("acqid");
var str;
for(var i = 0; i < a.length; i++)
{
if(a[i].checked==true)
{
alert(a[i].value);
}
}
}
<table>
<tr>
<td><input type="checkbox" name="acqid" value="3"> </td>
<td>3</td>
<td>3</td>
</tr>
<tr>
<td><input type="checkbox" name="acqid" value="4" > </td>
<td>4</td>
<td>4</td>
</tr>
</table>
<A href="javascript:deleteInfo()">delete </A> 可以看懂吧?你自己再改改.
function deleteInfo(){
var a = document.getElementsByName("acqid");
var str = "";
for(var i = 0; i < a.length; i++)
{
if(a[i].checked==true)
{
str+=a[i].value+",";
}
}
window.location.href="viewAcquisition.do?method=delete&acqid"+str;
}
</script><logic:iterate id="acq" name="acquisitionf">
<tr>
<td>
<input type="checkbox" name="acqid" value=${acq.id } >
</td>
<td>${acq.id} </td>
<td>${acq.createtime} </td>
<td>${acq.manager } </td>
<td>${acq.userNo} </td>
<td>${acq.scrapDoc } </td>
<td>${acq.scrapClear } </td>
</tr>
</logic:iterate>
<A href="javascript:deleteInfo()">删除 </A> 后台:
String ids = request.getParameter("acqid");//ids是以,分隔的数组
String strs = ids.split(",");//迭代取出id,最后一个元素是"",可以判断一下,或前台判断也可以.