Jump to content

Modifying A Table?


Recommended Posts

Grow the table as how? Do u mean add <td> or <tr> tags(s) to the existing one(s)? If dats what you mean, here is an ex:

function growTB(theTable){tr=document.createElement('tr');td=document.createElement('td');td.settAttribute('style','width:200px; height:100px;')tr.appendChild(td);document.getElementById(theTable).appendChild(tr)}

The above, creates a new row, with a td inside.CALL


Edited by eTianbun
  • Like 1
Link to comment
Share on other sites

The problem is that you're going to have trouble because you're supposing there's no <tbody> element. The <tbody> element is required and the browser puts it whether or not it's in the code. Putting the <tr> as a direct child of the table in Javascript will not work right. It's best to use the insertRow() method of the table object and insertCell() method of the created row. Examples of usage are right there in the method descriptions.

Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Create New...