求countchild的合计值?是所有countchild的值的总和吗?
var countchildList = document.getElementsByName("countchild");
var total = 0;
for(var i;i<countchildList.length;i++){
  total += parseInt(countchildList[i].value);
}

解决方案 »

  1.   

    <html><head>
    <meta http-equiv="Content-Type" content="text/html; charset=gb2312">
    <title>JK:支持民族工业,尽量少买X货</title><style>
    TD,INPUT{ font-size:12; }
    </style>
    </head><body bgcolor=EEEEEE>
    <form name="frm" action="about:结果页面" method=post >
    <h4 align=center>JK的动态明细示例</h4><table align="center" bordercolor=cccccc border=1  width=100% >
    <tr>
    <td width=500>
    </td>
    <td align=right>
          <input type="button"  value="增加" class="bottom" onclick="addDetailProcess();">&nbsp;     
          <input type="button"  value="删除" class="bottom" onclick="delDetailProcess();">&nbsp;     
          <input type="button"  value="完成" class="bottom" onclick="submitProcess();">
          
    </td>
    </tr>
    </table>
    <div width=100% id=thedetailtableDIV>
    <table align="center" bordercolor=cccccc border=1 width=100% >
      <tr bgcolor=eeeeee id="trDetailTitles"> 
        <td ><input type=checkbox onclick="selectallcheckbox(this)"></td>
        <td >明细ID*</td>
        <td >明细NAME</td>
        <td >明细Quantity</td>
      </tr>
      <tbody id="tbDetailUsed" >
    <tr>
    <td ><input type="checkbox" name="record_select" ></td>
    <td ><input type="text" name="detail_id" value='' ></td>
    <td ><input type="text" name="detail_name" value='' ></td>
    <td ><input type="text" name="detail_quantity" value='' onblur="resetTotalTdFun();"></td>
    </tr> <tr height=0 ><td colspan=3 height=0 align=right > 合计</td><td id=totalTd>0</td></tr>
      </tbody> </table>
    </div>
    </form><!--复制的内容-->
    <table id="tbDetailPrepare" style="display:none">
    <tr>
    <td ><input type="checkbox" name="record_select" ></td>
    <td ><input type="text" name="detail_id" value='' ></td>
    <td ><input type="text" name="detail_name" value='' ></td>
    <td ><input type="text" name="detail_quantity" value='' onblur="resetTotalTdFun();"></td>
    </tr>
    </table>
    <input name="theHistoryRecord" type=hidden value="">
    </body></html><script language=javascript> window.onload = historyOncemore;
    window.onbeforeunload = fixHistory; function fixHistory() //记住历史
    {
    document.all("theHistoryRecord").value=document.all("thedetailtableDIV").innerHTML.replace(/\n/g,"");
    } function historyOncemore() //恢复历史
    {
    if (document.all("theHistoryRecord").value!="")
    {document.all("thedetailtableDIV").innerHTML=document.all("theHistoryRecord").value;
    }
    } function selectallcheckbox(obj) //全选或全不选
    {
    var tureorfalse=obj.checked;
    var theDetail=tbDetailUsed.rows;
    for(var i=0;i<theDetail.length-1;i++)
    {
    theDetail[i].all("record_select").checked=tureorfalse;
    }
    }


    function addDetailProcess(afterRowIndex) //增加明细
    {
    var alltbDetailUsed= document.all("tbDetailUsed").rows;
    var theFirstSelectedDetail;
    if (afterRowIndex==null)
    {
      theFirstSelectedDetail=alltbDetailUsed.length-2;
    }
    else theFirstSelectedDetail=afterRowIndex;
    var newRow = document.all("tbDetailPrepare").rows[0].cloneNode(true);
    var desRow = alltbDetailUsed[theFirstSelectedDetail+1];
    desRow.parentElement.insertBefore(newRow,desRow ); }

    function delDetailProcess() //删除明细
    {
    var alltbDetailUsed= document.all("tbDetailUsed").rows;
    if (confirm("确定选择正确并且要将这些明细删除")==false) return false;
    for(var i=0;i<alltbDetailUsed.length-1;i++)
    {
    if (alltbDetailUsed[i].all("record_select").checked==true)
    {
    document.all("tbDetailUsed").deleteRow(i);
    i=i-1;
    }
    }
    resetTotalTdFun();
    } function submitProcess()
    {
    document.frm.submit();
    } function resetTotalTdFun()
    { var quantityObjs=document.getElementsByName("detail_quantity");
    var tempTotal=0;
    for(var i=0;i<quantityObjs.length-1;i++)
    tempTotal+=quantityObjs[i].value*1;
    totalTd.innerText=tempTotal;
    }</script>
      

  2.   

    我不大明白你的意思,
    我说下我的理解:1你新建了一个table1
    2然后你在table1的某个TR1_X后插入一个新的同级TR1_X+1
    3你接着向这个TR1_X+1加入被包含的TD,并设这个TD的内容是一个table1_1,table1_1只有一个TD,包含维一的INPUT1_1_1;4重复2,3步骤X次
    5要取得所有的INPUT1_1_1;要是这样的话,你可以这样:var object
    for(var i0;i0 < table1.rows.length;i0++){//所有的第一层表格的TR
            for(var i1;i1 < table1.rows[i0].cells.length;i1++){//所有的第一层表格的TR的所有TD
                if(  (object=table1.rows[i0].cells[i1].children[0]).tagName == "TABLE"){//检查此TD中是不是一个表格,前提只有用于你上面的那个TD才插入表格;
                     alert(object.innerText + "\t" + object.rows[0].cells[0].children[0].value);
                }
            }
    }如果你是新table0
    1然后在table0的第X个TR的第Y个TD加入table1,
    2再在table1第X个TR的第Y个TD加入table1
              .
              .
              .
    最后在tableN第X个TR的第Y个TD加入tableN+1,并在tableN+1的第1个TR加入TD,在此TD中加入INPUT
    更有可能在TABLEZ的第Z个TD又分出一支的话,这你只能像在C盘下找到所有的TXT文件一件了,
    我不知杀毒的如何操作,我的想法是,有一个数组,用于记录未完成的文件夹,当打开某个文件夹时,就先检测此文件夹下的文件合不合,在此文件夹下找到文件夹就加入文件夹数组,然后选择数组中的一个下标再如此检查,并删除此下标,再找到文件夹又加入,直到数组为0;3