AlbertAguirre
Programmer
New to JS. Please help?
Why doesnt this function insert 10 rows?
upon execution it inserts one row but it DOES iterate through the loop 10 times.
function insRow(pTable){
var dynamicTable=document.getElementById(pTable).insertRow(0)
var cell01=dynamicTable.insertCell(0)
var cell02=dynamicTable.insertCell(1)
var i=0
while (i<=10){
cell01.innerHTML="NEW CELL1"
cell02.innerHTML="NEW CELL2"
i=i+1
}
}
</script>
Why doesnt this function insert 10 rows?
upon execution it inserts one row but it DOES iterate through the loop 10 times.
function insRow(pTable){
var dynamicTable=document.getElementById(pTable).insertRow(0)
var cell01=dynamicTable.insertCell(0)
var cell02=dynamicTable.insertCell(1)
var i=0
while (i<=10){
cell01.innerHTML="NEW CELL1"
cell02.innerHTML="NEW CELL2"
i=i+1
}
}
</script>