首先我们知道要删除记录就必须有主键,所以在写的时候让checkbox的值等于主键的值就向下面
while(!rs.eof){
out.print("字段一");
out.print("字段二");
out.print("字段三");
out.print(“<input type=checkbox name=rowid value="+(String)rs.getObject("row_id")+">”)
}、
//row_id 为表中的主键然后在点击“删除行”的按钮在后台有一个rowid的数组去接收checkbox的值,这样不就可以删除了吗?不过接收的方法好像是 String [] rowid=request.getParameterName("rowid");
我忘记了,你可以试一试,很多编辑器都能点的出来的,看看返回类型是数组的就对了。嘿嘿试一试吧
while(!rs.eof){
out.print("字段一");
out.print("字段二");
out.print("字段三");
out.print(“<input type=checkbox name=rowid value="+(String)rs.getObject("row_id")+">”)
}、
//row_id 为表中的主键然后在点击“删除行”的按钮在后台有一个rowid的数组去接收checkbox的值,这样不就可以删除了吗?不过接收的方法好像是 String [] rowid=request.getParameterName("rowid");
我忘记了,你可以试一试,很多编辑器都能点的出来的,看看返回类型是数组的就对了。嘿嘿试一试吧
接收的方法是 String [] rowid=request.getParameterName("rowid");
现在我是要在jsp页面中删除table中的一行下面列出我的部分jsp代码(包括form和table部分)
现在的问题就是按钮“删除行”的onclick方法deleteRow()怎么写?
再次谢谢你们的鼎力相助!<form>
<table width="98%" border="1" align="center" id="detailTable">
<tr>
<th scope="col">船名</th>
<th scope="col">驳数</th>
<th scope="col">货种</th>
<th scope="col">功率</th>
<th scope="col">到达指定水域<input type="checkbox" name="chkall" value="on" onclick="CheckAll(this.form)" title="点击可全选中本页的所有船舶"></th>
</tr>
<ww:iterator value="#info.framePlan.planDamgateDetails">
<tr>
<td><ww:property value="shipApplyInfo.shipBasicInfo.shipName"/></td>
<td><ww:property value="shipApplyInfo.gbDragCount"/></td>
<td><ww:property value="shipApplyInfo.gbGoodsType.codeName"/></td>
<td><ww:property value="shipApplyInfo.shipBasicInfo.mainPower"/></td>
<td><input type="checkbox" name="arrivedSXBerth" value="true" <ww:if test="shipApplyInfo.arriveGBBerth == true">checked</ww:if>></td>
</tr>
</ww:iterator>
</table>
<input type="button" value="删除行" onclick="deleteRow()">
</form>
用下面这个吧
在form中加上一个隐含属性吧
<input type=hidden name=hidRid value=主键>
将这个隐含属性加入到你的迭代标签中且该值设置为主键
在加入一个隐含属性来获取最终的值:(该隐含属性加到按钮上面就可以了)
<input type=hidden name=hidRowid>deleteRow(){
for(var i=0;i<formName.arrivedSXBerth.length;i++)
if(formName.arrivedSXBerth[i].checked){
formName.hidRowid=formName.hidRowid+formName.hidRid[i].value+"%";
}
}
}
在后台接收hidRowid就会像 2%3%,然后将2和3主键取出然后执行删除动作
<html:checkbox property="name" value="张三" checked="checked">张三</html:checkbox>
<html:checkbox property="name" value="李四" checked="checked">李四</html:checkbox>
<html:checkbox property="name" value="王五" > </html:checkbox>这里有三个选项,只有 张三、李四被选中。在你的应用中,你可以定义一个数组,
String[] names=request.getParameterValues("name");这个时候 names 就自动只取了选中的项,
int sum=names.length; //这里i等于2然后就可以利用 for 循环对提交的信息进行处理了!
for( int i = 0; i < sum ; i ++){ out.println(names[i]); //实际的业务}祝你早日克服^o^
1。给tr设定document内的唯一id,定义style='display:' 或style='display:'(隐藏否的设置)
<tr id='subMenu" style='display:none'>
2。用javascript控制
function showMenu(menuObj,isSub){
if(menuObj.style.display=="none"){
menuObj.style.display="";
}