如代码如下:
<TABLE   border="0" width="50%"  id="activeTable1">
                  </TABLE>
                    <p>
                      <input type="button" name="Submit3" value="  增 加 备 件  "  onclick="AddRecord1()" >
                      <script> 
  function getback(obj)
                         {
     var td = obj.parentNode;
     var dangjia = td.previousSibling.firstChild;
     var shuliang = td.previousSibling.previousSibling.firstChild;
     obj.value = (shuliang.value * dangjia.value).toFixed(2);
}   
  function   AddRecord1()   
  {   
  var   row   =   activeTable1.insertRow(activeTable1.rows.length);//id=recordTable     
  var   col   =   row.insertCell(0);   
  var   i   =   row.rowIndex;   
  col.innerHTML   =   "<input   type='text'   name='texth' size='30' value=''>"; 
  col   =   row.insertCell(1); 
  col.innerHTML   =   "<input   type='text'   name='guige' size='20' value=''>"; 
  col   =   row.insertCell(2);     
  col.innerHTML   =   "<input   type='text'   name='texti' size='10'   value=''>"; 
  col   =   row.insertCell(3);     
  col.innerHTML   =   "<input   type='text'   name='textj'  size='10'  value=''>";
  col   =   row.insertCell(4);     
  col.innerHTML   =   "<input   type='text'   name='textk'  size='15'  onClick='getback(this)'; value=''>";
   col   =   row.insertCell(5);     
  col.innerHTML   =   "<input   type='hidden'   name='textl'    value='"+i+ "'>"; 
  col   =   row.insertCell(6);     
  col.innerHTML   =   "<input   type='button'   name='button1' onclick='delRow(this)' value='删除'>";   
          
  }   
                    function isEmpty(txt){
        var v = txt.value.replace(/(^\s*)|(\s*$)/g, "");//去除首位空格
        if(v.length == 0){
            alert("不能为空!");
            txt.focus();
            return false;
        }
        return true;
    }

    function subValidate1(){
        var txts = activeTable.getElementsByTagName("input");
    for(var i=0;i<txts.length;i++){
        if(txts[i].type.toLowerCase() == "text" && !isEmpty(txts[i])){
            return false;
        }
    }
    return true;
    }
                            </script>
                    &nbsp;
                    <input name="Submit4" type="submit" id="Submit4"    onclick="return subValidate1();" value="  保存备件材料 ">
                  </td>
              </tr>
            </table>
                    </form>  

解决方案 »

  1.   

    var txts = activeTable.getElementsByTagName("input");
    --------->换成:
    var txts = document.getElementsByTagName("input");
      

  2.   

    在ie下activeTable.getElementsByTagName("input");这样是可以的
      

  3.   

    <TABLE border="0" width="50%" id="activeTable1">
      </TABLE>
      <p>
      <input type="button" name="Submit3" value=" 增 加 备 件 " onclick="AddRecord1()" >
      <script>  
    function getback(obj)
      {
      var td = obj.parentNode;
      var dangjia = td.previousSibling.firstChild;
      var shuliang = td.previousSibling.previousSibling.firstChild;
      obj.value = (shuliang.value * dangjia.value).toFixed(2);
    }   
      function AddRecord1()   
      {   
      var row = activeTable1.insertRow(activeTable1.rows.length);//id=recordTable   
      var col = row.insertCell(0);   
      var i = row.rowIndex;   
      col.innerHTML = "<input type='text' name='texth' size='30' value=''>";  
      col = row.insertCell(1);  
      col.innerHTML = "<input type='text' name='guige' size='20' value=''>";  
      col = row.insertCell(2);   
      col.innerHTML = "<input type='text' name='texti' size='10' value=''>";  
      col = row.insertCell(3);   
      col.innerHTML = "<input type='text' name='textj' size='10' value=''>";
      col = row.insertCell(4);   
      col.innerHTML = "<input type='text' name='textk' size='15' onClick='getback(this)'; value=''>";
      col = row.insertCell(5);   
      col.innerHTML = "<input type='hidden' name='textl' value='"+i+ "'>";  
      col = row.insertCell(6);   
      col.innerHTML = "<input type='button' name='button1' onclick='delRow(this)' value='删除'>";   
        
      }   
      function isEmpty(txt){
      var v = txt.value.replace(/(^\s*)|(\s*$)/g, "");//去除首位空格
      if(v.length == 0){
      alert("不能为空!");
      txt.focus();
      return false;
      }
      return true;
      }
      //LZ你把table的ID改了,这里的也要改啊
      function subValidate1(){
      var txts = document.getElementById("activeTable1").getElementsByTagName("input");
      for(var i=0;i<txts.length;i++){
      if(txts[i].type.toLowerCase() == "text" && !isEmpty(txts[i])){
      return false;
      }
      }
    return true;
      }
      </script>
      &nbsp;
      <input name="Submit4" type="submit" id="Submit4" onclick="return subValidate1();" value=" 保存备件材料 ">
      </td>
      </tr>
      </table>
      </form>