frontline
09-24-2003, 12:06 PM
Hello
i have simple script ,one function builds rows and one (supposed to ..) delete all the rows
but the delete rows function dont delete all the rows , im using the deleteRows(n) dhtml function
here is the code :
------------------------------------------------------------------------------
<HTML>
<HEAD>
<script>
function setTable(){
var oRow,oCellText;
var arrNames = "blah1|blah2|blah3|blah4|";
arrNames = arrNames.split("|");
for(var i=0;i<arrNames.length-1;i++){
oRow = TableFirst.insertRow();
oCellText = oRow.insertCell();
oCellText.innerHTML = arrNames[i];
}
}
function delTable(){
if(TableFirst.rows.length > 0){
var rowLength = parseInt(TableFirst.rows.length);
for(var j=0;j<rowLength;j++){
document.getElementById("TableFirst").deleteRow(j);
}
}
}
</script>
</HEAD>
<BODY>
<input type="button" onclick="setTable();" value="build"><br>
<input type="button" onclick="delTable();" value="Delete"><br>
<table id="TableFirst" border="1" cellspacing="0" cellpadding="0" width="100%" class="font"></table>
</BODY>
</HTML>
--------------------------------------------------------------------------------
what im doing wrong here?
thanks
i have simple script ,one function builds rows and one (supposed to ..) delete all the rows
but the delete rows function dont delete all the rows , im using the deleteRows(n) dhtml function
here is the code :
------------------------------------------------------------------------------
<HTML>
<HEAD>
<script>
function setTable(){
var oRow,oCellText;
var arrNames = "blah1|blah2|blah3|blah4|";
arrNames = arrNames.split("|");
for(var i=0;i<arrNames.length-1;i++){
oRow = TableFirst.insertRow();
oCellText = oRow.insertCell();
oCellText.innerHTML = arrNames[i];
}
}
function delTable(){
if(TableFirst.rows.length > 0){
var rowLength = parseInt(TableFirst.rows.length);
for(var j=0;j<rowLength;j++){
document.getElementById("TableFirst").deleteRow(j);
}
}
}
</script>
</HEAD>
<BODY>
<input type="button" onclick="setTable();" value="build"><br>
<input type="button" onclick="delTable();" value="Delete"><br>
<table id="TableFirst" border="1" cellspacing="0" cellpadding="0" width="100%" class="font"></table>
</BODY>
</HTML>
--------------------------------------------------------------------------------
what im doing wrong here?
thanks