Guest fabkins Posted November 29, 2006 Share Posted November 29, 2006 There is an error with the JS DOM Delete Row example. The call makes the assumption that the "deleterow" property is available to a button which is not the case. This causes the example to always delete the first row instead of the row for which the button was pressed.The following is a working version of the example where i get the parent of the button (which is the cell) and then the parent of the cell to get the row. From there it can get the correct rowIndex. <html><head><script type="text/javascript">function deleteRow(r) { i=r.parentNode.parentNode.rowIndex document.getElementById('myTable').deleteRow(i) }</script></head><body><table id="myTable" border="1"><tr> <td>Row 1</td> <td><input type="button" value="Delete" onclick="deleteRow(this)"></td></tr><tr> <td>Row 2</td> <td><input type="button" value="Delete" onclick="deleteRow(this)"></td></tr><tr> <td>Row 3</td> <td><input type="button" value="Delete" onclick="deleteRow(this)"></td></tr></table></body></html> I am new to w3schools and this forum, I appologies if I posted this in the wrong place. Link to comment Share on other sites More sharing options...
Skemcin Posted November 29, 2006 Share Posted November 29, 2006 Thank you for reporting the error and welcome to the forums. The moderator team is not directly related to the owners (and therefore maintenance) of the site. We will pass this along but we are unable to give you any indication when the error will be remedied.Thanks again and we look forward to your contributions. Link to comment Share on other sites More sharing options...
Jonas Posted November 29, 2006 Share Posted November 29, 2006 You can also follow this link:http://www.w3schools.com/about/about_helping.aspand follow the instructions there on helping correct errors. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now