首先我们知道要删除记录就必须有主键,所以在写的时候让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");
我忘记了,你可以试一试,很多编辑器都能点的出来的,看看返回类型是数组的就对了。嘿嘿试一试吧

解决方案 »

  1.   

    JSP文件中:<input type=checkbox name=rowid value="+(String)rs.getObject("row_id")+">
    接收的方法是 String [] rowid=request.getParameterName("rowid");
      

  2.   

    非常感谢楼上的几位!可能是我没表达清楚
    现在我是要在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()">&nbsp;&nbsp;&nbsp;
    </form>
      

  3.   

    难道不是选择一个或多个多选框然后点击删除按钮后删除所选择的行吗?
    用下面这个吧
    在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主键取出然后执行删除动作
      

  4.   

    我也问过类似的问题,社区的好心人告诉我一个好方法,如果你也是每行后面有一个checkbox的话,你不妨把所有的checkbox设成同名,解决原文如下:首先这些 checkbox 必须具有相同的 property(设为主键,好删除数据库表项),然后用 value 对他们加以区别,
    <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^
      

  5.   

    可以,变相删除:隐藏
    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="";
    }