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 Link to comment https://forums.phpfreaks.com/topic/241682-get-the-innerhtml-of-a-td-when-passing-this-and-table-id/ 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. Link to comment https://forums.phpfreaks.com/topic/241682-get-the-innerhtml-of-a-td-when-passing-this-and-table-id/#findComment-1241290 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); } Link to comment https://forums.phpfreaks.com/topic/241682-get-the-innerhtml-of-a-td-when-passing-this-and-table-id/#findComment-1241303 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.