<script>
function deleteRow(obj)
{
obj.parentNode.parentNode.removeNode(true);
}
</script>
<body>
<table>
<tr><td>AAAAAAA</td><td><input type=checkbox onclick="if(this.checked)deleteRow(this)">删除行</td></tr>
</table>
</body>
function deleteRow(obj)
{
obj.parentNode.parentNode.removeNode(true);
}
</script>
<body>
<table>
<tr><td>AAAAAAA</td><td><input type=checkbox onclick="if(this.checked)deleteRow(this)">删除行</td></tr>
</table>
</body>
而与复选框在同一行的其他元素并没有同时删除下面列出我的部分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>
function checkAll(){
var checkOne=document.all("checkOne");
if(document.all("checkAll").checked){
for(var i=0;i<checkOne.length;i++){
checkOne[i].checked=true;
}
}else{
for(var i=0;i<checkOne.length;i++){
checkOne[i].checked=false;
}
}
}
function checkOne(){
var checkOne=document.all("checkOne");
var j=0;
for(var i=0;i<checkOne.length;i++){
if(!checkOne[i].checked){
document.all("checkAll").checked=false;
}else{
j++;
}
}
if(j==checkOne.length){
document.all("checkAll").checked=true;
}
}
function remove(){
var checkOne=document.all("checkOne");
var url="savedoc.jsp?idstr=";
if(typeof(checkOne)=="undefined"||checkOne==null){return;}
var checkBoxGroupValue=getCheckBoxGroupValue(checkOne);
if(checkBoxGroupValue.length<1){
alert("没有选中记录,无法进行删除!");
}else if(confirm("确认删除所选记录吗?")){
url+=checkBoxGroupValue;
//location.href=url;
window.open(url,'gd_detail','height=220, width=350, toolbar=no, menubar=no, scrollbars=yes, resizable=no, location=no, status=no');
}
}function getCheckBoxGroupValue(cbg){
if(cbg==null) return "";
s="";
if(typeof(cbg)!='undefined' && cbg!=null){
if(typeof(cbg[0])=='undefined' || cbg[0]==null){
if(cbg.checked) s=cbg.value;
}else{
s="";
for(var i=0;i<cbg.length;i++){
if(cbg[i].checked){
s+=","+cbg[i].value;
}
}
s=s.substring(1);
//alert(s);
}
}
return s;
}
</script>