Jump to content
Sign in to follow this  
bijan

Delete all rows

Recommended Posts

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 ?

Share this post


Link to post
Share on other sites

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. :)

Share this post


Link to post
Share on other sites
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. :)

replace td with trtd are the cells tr are the rows which you asked for :)

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
Sign in to follow this  

×
×
  • Create New...