Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Adding rows to a table

Status
Not open for further replies.

krkX

Programmer
Nov 12, 2000
54
NL
Hello,

I have no clue how to add a new row to a table using DHTML, cant use the [table id].innerHTML method.

Is there anyway of doing this...??

A push in the right direction would do,

Thanx

krkX X-)
 
you cant write html tags after the page has finished loading, you would have to write the number of rows in a querystring and reload the page, or maybe you could make all the rows sized 0 and with no border and then change the properties... -Greg :-Q

flaga.gif
 
what about dom?

Code:
<html><head><title>create a table row</title>
<script>
<!--
function createRow(menuid){
var daRow;
	daRow = document.createElement(&quot;TR&quot;);
	daTd = document.createElement(&quot;TD&quot;);
	datext=document.createTextNode(&quot;theText&quot;);
	daTd.appendChild(datext);
	with(daRow){
		appendChild(daTd);
	}
	document.getElementById(&quot;_tbody&quot;).appendChild(daRow);
}	
//-->
</script>
</head>
<body>
<form name=my>
<input type=&quot;button&quot; value=&quot;create row&quot; onclick=&quot;createRow('aa')&quot;><br>
<input type=&quot;button&quot; value=&quot;html&quot; onclick=&quot;alert(document.body.innerHTML)&quot;><br>
</form>
<table >
<tbody id=&quot;_tbody&quot;>
<tr >
<td>old row</td>
</tr>
</tbody>
</table>
</body>
</html>

without DOM & innerHTML, i don't know what to suggest.. :( Victor
 
oh, i didnt think you could write html (besides filling in text) after the page was loaded, that might not be supported by all browsers (netscrap) though, right? -Greg :-Q

flaga.gif
 
Yeah Greg, I didn't think you could either. Then I saw this post surface the other day and I though WOW !! that's really neat, so I replied back to the originator telling him how cool I though his script was.

His reply was... Wow, I didn't think anyone replied to these posts after a year !! I looked closer at the post and sure enough, this was being done back in October, 2000 (and probably earlier).

Guess I'm still in the dinosaur ages. I remember thinking that I thought the poster was sort of braggish when he started the post with, &quot;I don't know if I'm the first one to figure this out or not..&quot; because I thought while it was pretty neat, it didn't seem revolutionary or anything like that. Then I realized the post was 13 months old. LOL

Here's the thread.. thread216-31927

I like this one because it generates new form elements along with the table rows and is ASP ready.

ToddWW
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top