bijan Posted February 9, 2006 Share Posted February 9, 2006 How can I delete all the rows of the table ?I know thedocument.getElementById('tbl').deleteRow(i)But how can I know the quantity of the table rows ?So that I can make a for loop and delete them all ? Link to comment Share on other sites More sharing options...
Chocolate570 Posted February 9, 2006 Share Posted February 9, 2006 What you could do is add this to your 'table' tag. id="tblRowDel" And to access how many table rows there are, you do this: x=document.getElementById("tblRowDel")x=x.getElementsByTagName("td")y=x.length Now, you can use Y with your for loop. Y contains the number of TD's in your table. Link to comment Share on other sites More sharing options...
aspnetguy Posted February 9, 2006 Share Posted February 9, 2006 What you could do is add this to your 'table' tag.id="tblRowDel" And to access how many table rows there are, you do this: x=document.getElementById("tblRowDel")x=x.getElementsByTagName("td")y=x.length Now, you can use Y with your for loop. Y contains the number of TD's in your table. <{POST_SNAPBACK}> replace td with trtd are the cells tr are the rows which you asked for Link to comment Share on other sites More sharing options...
bijan Posted February 9, 2006 Author Share Posted February 9, 2006 I used :document.getElementById('table_id').rows.lengthIt works fine with me 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