1.http://www.csdn.net/expert/topic/637/637044.xml?temp=.6986048
2.http://www.csdn.net/expert/topic/971/971346.xml?temp=.5859186

解决方案 »

  1.   

    1.最好在每个tr中放一个删除按钮写上onclick="delitem(this)"
    function delitem(obj){
       table1.tbody1.deleterow(obj.offsetParent.parentElement.rowIndex)
    }
    2.用数组如名称为ridaos
    ridaos[0]为第一个名为ridaos物件,
    ridaos[1]为第二个名为ridaos物件,
    ........
    3.tdd.onclick=function anonymous() { delitem(arguments) }
      

  2.   

    function delitem(obj){
       table1.tbody1.deleterow(obj.offsetParent.parentElement.rowIndex)
    }
    这句话有问题
    好像是删除最上面一行
    而不是当行
      

  3.   

    把源代码和意图写出来可能解决方法是
    1.for (i=tbl.rows.length-1;i>=0;i--){
    2.tbl.deleteRow(i--);
    3.tbl.deleteRow(i);break;
      

  4.   

    <HTML>
    <HEAD>
    <TITLE> 编辑正常价 </TITLE>
    <link rel="stylesheet" type="text/css" href="../inc/style.css">
    <meta http-equiv="Content-Type" content="text/html;charset=gb2312;">
    </HEAD>
    <BODY bgcolor="#FFFFFF" background="../inc/bj1.jpg">
    <script language=javascript src="../inc/calendar.js"></script>
    <%
    if request("room_id")<>"" then 
    sql="select * from hotel_price where sign = 0 and room_id = '"&trim(request("room_id"))&"'"
    rs.open sql,jsxcon,1
    else
    response.write "参数错误"
    response.end
    end if
    firstcount=rs.recordcount
    %>
    <form name="forma" method="post" action="aa.asp" onsubmit="javascript:return checkin();">
      <table width="80%" border="1" cellspacing="1" cellpadding="1" id=addtbl>
    <tr align="center" id=tra name=tra > 
      <td width="23%" height="9">开始时间<input type=hidden name=start_date-0 value=0></td>
      <td width="23%" height="9">结束时间 <input type=hidden name=end_date-0 value=0 ></td>
      <td width="23%" height="9">底价<input type=hidden name=bottom_price-0 value=0 ></td>
      <td width="8%" height="9">卖价<input type=hidden name=sale_price-0 value=0 ></td>
      <td width="23%" height="9">早餐<input type=hidden name=breakfast-0 value=0 ></td>
      <td width=5%>&nbsp;</td>
    </tr>
    <%
    While not (rs.eof or rs.bof)
    %>
    <tr align="center" id='tra' name="tra" ln='<%=acount%>' > 
      <td width="23%" height="6" ln='<%=acount%>'> 
    <input type="text" value="<%=rs("start_date")%>" name="start_date-<%=rs("id")%>" onFocus="javascript:calendar(this);">
      </td>
      <td width="23%" height="6" ln='<%=acount%>'> 
    <input type="text" name="end_date-<%=rs("id")%>" value="<%=rs("end_date")%>" onFocus="javascript:calendar(this);">
      </td>
      <%
      %>
      <td width="23%" height="6" ln='<%=acount%>'> 
    <input type="text" name="bottom_price-<%=rs("id")%>" value="<%=rs("bottom_price")%>" >
      </td>
      <td width="8%" height="6" ln='<%=acount%>'> 
    <input type="text" name="sale_price-<%=rs("id")%>" value="<%=rs("sale_price")%>">
      </td>
      <td width="23%" height="6" ln='<%=acount%>'> 
    <input type="text" name="breakfast-<%=rs("id")%>" value='<%=rs("breakfast")%>' >
      </td>
      <td onclick='delit();' id=ri ln='<%=acount%>' width=5% >删除</td>
    </tr>
    <%
    rs.movenext
    Wend
    %>
    </table>
    <table border=1 cellspacing=0 cellpadding=0 width=80% >
    <tr> 
      <td colspan="5" height="10"> 
    <input type="submit" name="Submit" value="增加">
    <input type=button onclick='additem();' value='增加一行' >
    <input type="button" name="Submit2" onclick="history.back();" value="取消">
    <input  type=hidden name=room_id value="<%=request("room_id")%>">
    <input type=hidden name=hotel_id value="<%=request("hotel_id")%>">
    <input type=hidden name="sign" value="<%=request("sign")%>" >
      </td>
    </tr>
      </table>
    </form>
    </BODY>
    </HTML>
    <SCRIPT LANGUAGE="JavaScript">
    <!--
    function checkin(){
    // alert(document.forma.all("start_date").length)
    for (i=0;i<document.forma.all("start_date").length;i++){
    if(document.forma.start_date(i).value.length==0)
    {
    alert("选择开始日期!");
    document.forma.start_date(i).select();
    return false;
    }
    if (document.forma.end_date(i).value.length==0){
    alert("选择结束日期把!");
    document.forma.end_date(i).select();
    return false;
    }
    if (document.forma.end_date(i).value < document.forma.start_date(i).value){
    alert("结束日期必须大于开始日期!");
    document.forma.end_date(i).focus();
    return false;
    } if (document.forma.bottom_price(i).value.length==0){
    alert("选择价格");
    document.forma.bottom_price(i).focus();
    return false;
    }
    else{
    digits="123456789.0";
    var chr;
    for(j=0;j<document.forma.bottom_price(i).value.length;j++){
    var chr=document.forma.bottom_price(i).value.charAt(j);
    if (digits.indexOf(chr,0)==-1){
    alert("请输入数值!");
    document.forma.bottom_price(i).value='';
    document.forma.bottom_price(i).focus();
    return false;
    }
    }
    }
    if (document.forma.sale_price(i).value.length==0){
    alert("选择卖价");
    document.forma.sale_price(i).focus();
    return false;
    }
    }
    }
    //-->
    </SCRIPT>
    <SCRIPT LANGUAGE="JavaScript">
    <!--
    allcount=<%=firstcount%>+2;
    temp=1;
    function additem(){
    newrow=addtbl.insertRow(addtbl.rows.length);
    newrow.id="tra";
    newrow.ln=allcount;
    newrow.bgColor="#FFFFFF";
    // newrow.onclick=aa; c1=newrow.insertCell(0);
    c1.id="aid"
    c1.ln=allcount;
    c1.innerHTML="<input type=text id='start_date' ln='"+allcount+"' size=20 onFocus='calendar(this)' name='start_date-"+temp+"'  >";
    c2=newrow.insertCell(1);
    c2.ln=allcount;
    c2.innerHTML="<input type=text id='end_date' ln='"+allcount+"' size=20 onFocus='calendar(this)' name='end_date-"+temp+"'  >";
    c3=newrow.insertCell(2);
    c3.ln=allcount;
    c3.innerHTML="<input type=text id='bottom_price' ln'"+allcount+"' size=20 name='bottom_price-"+temp+"' >";
    c4=newrow.insertCell(3);
    c4.ln=allcount;
    c4.innerHTML="<input type=text id='sale_price' ln='"+allcount+"' size=20 name='sale_price-"+temp+"' >";
    c5=newrow.insertCell(4);
    c5.ln=allcount;
    c5.innerHTML="<input type=text id='breakfast' ln='"+allcount+"' size=20 name='breakfast-"+temp+"' >";
    c6=newrow.insertCell(5);
    c6.ln=allcount;
    c6.onclick=delit;
    c6.innerHTML="删除"
    allcount++;
    temp++;
    }
    function delit(){
    alert(event.srcElement.ln);
    num=parseInt(event.srcElement.ln,10);
    if (num>0) {
    for (i=1;i<addtbl.rows.length;i++){
    // alert(tra[i].ln);
    if (tra[i].ln==num){
    {
    if (document.forma.all["start_date-"+i].value.length>0 || document.forma.all["end_date-"+i].value.length >0 || document.forma.all["bottom_price-"+i].value.length >0 || document.forma.all["sale_price-"+i].value.length >0 )
    { if (!confirm("Are you sure to delete it ?"))
    return 
    }
    addtbl.deleteRow(i);
    }
    }
    }
    }
    }
    //-->
    </SCRIPT>
    实在不想把代码贴出来?
    没有办法
    谢谢了
      

  5.   

    tryif (confirm("Are you sure to delete it ?")){addtbl.deleteRow(i);return ;}
      

  6.   

    第一个问题,楼上的应该可以第二个:
    检测重名组件的,可以参考以下程序:
    //是否选择
    function ifChecked(ChkName){
    var aa = document.getElementsByTagName("input");
    for (var i = 0; i<aa.length; i++)
    if(aa[i].name==ChkName && aa[i].checked)
    return true;return false;
    }第三个,好像不行,你还是在控件上加onclick吧
    像你程序中,调用delitem函数,
    直按可以写:delitem(参数),不需要tdd.onclick=delitem