davej Posted October 15, 2011 Share Posted October 15, 2011 This is something I have not had any success with. What if you want to display a table and then in response to a button click you want to call a function that would grow the table? Thanks! Link to comment Share on other sites More sharing options...
eTianbun Posted October 15, 2011 Share Posted October 15, 2011 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 growTB('Table_ID') Link to comment Share on other sites More sharing options...
davej Posted October 16, 2011 Author Share Posted October 16, 2011 Thanks! I will give that a try. Link to comment Share on other sites More sharing options...
Ingolme Posted October 16, 2011 Share Posted October 16, 2011 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 More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.