petrakid 0 Newbie Poster

I have two scripts. The first script creates a row in a table:

function addRow(tblId)
{
     if(counter == limit) {
          alert("You cannot add more than " + limit + " passages!");
     } else {
	    var tblBody = document.getElementById(tblId).tBodies[0];
	    var newNode = tblBody.rows[0].cloneNode(true);
	    tblBody.appendChild(newNode);
         counter++;
     }
}

... the second is supposed to delete the last row created (and subtract from the max rows count):

function deleteRow(tblId)
{
     var tblBody = document.getElementById(tblId).tBodies[0];
     var lastRow = document.getElementById(tblId).rows.length;
     if(lastRow == 1) {
          alert("Cannot delete first row!");
     } else {
          tblBody.deleteRow(lastRow); 
          counter = counter - 1;
     }
}

However the deleteRow function is NOT deleting rows (when I push the button with the onclick=deleteRow('scripturetable') ). I know the function is being called, as, when there's only one row, the alert pops up, but that's it.

Any help would be appreciated!

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.