freelance84 Posted July 11, 2011 Share Posted July 11, 2011 This function simply removes a table row: The HTML: <td> <input type="button" value="X" onclick="deleteRow(this,'myTable');"/> </td> The js function function deleteRow(r,tableID){ var i=r.parentNode.parentNode.rowIndex; document.getElementById(tableID).deleteRow(i); } I am trying to write another function which will get the innerHTML of the 1st table cell in the same row, but not sure how. I found this thread on google : thread and this thread But they all seem to cycle through the whole table. Again, this is a new area for me so any pointers to a good tutorial would be awesome if you know any... or how to do it even better Quote Link to comment Share on other sites More sharing options...
joe92 Posted July 11, 2011 Share Posted July 11, 2011 This example on w3 achieves what your asking I think. Quote Link to comment Share on other sites More sharing options...
freelance84 Posted July 11, 2011 Author Share Posted July 11, 2011 Awesome, thanks for the link. Rearranged to this: HTML: onclick="getRow('theURLTable',this,'0');" the JS function getRow(tableID,thisRow,cellNumber){ var i=thisRow.parentNode.parentNode.rowIndex; var x=document.getElementById(tableID).rows[i].cells; alert(x[cellNumber].innerHTML); } Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.