2010-11-02 51 views

回答

1

計數行可以理解

<script type="text/javascript"> 
function addRow() { 
var newRow = document.all("tblGrid").insertRow(); 
oCell = newRow.insertCell(); 
oCell.innerHTML = "<input type='text' name='t1'><input type='button' value='Delete' onclick='removeRow(this);'/>"; 
//if(oCell>=5)return; 
} 
</script> 

預先感謝。行只是表元素中的數組 - 歡迎您 - 您可以通過length

<script type="text/javascript"> 
function addRow() { 
    if (document.all("tblGrid").rows.length == 5) { 
     return; // already max 5 rows 
    } 
    var newRow = document.all("tblGrid").insertRow(); 
    oCell = newRow.insertCell(); 
    oCell.innerHTML = "<input type='text' name='t1'><input type='button' value='Delete' onclick='removeRow(this);'/>"; 
} 
</script> 
+0

它的工作原理,你太棒了,非常感謝 – user485783 2010-11-02 06:29:20

+0

@user得到它的長度。隨意遵循通常的計算器自定義,如果答案有幫助,請通過單擊旁邊的複選標記來接受它,並通過單擊向上箭頭向上投票。謝謝! – DVK 2010-11-02 07:04:10

+0

我做過了,但是當我點擊向上箭頭時,出現的消息是「投票需要15個聲望」,所以我失敗了。我很抱歉,我是新的stackoverflow我不知道如何提高我的聲譽。 – user485783 2010-11-04 04:34:23

0
​​