duplicate my table

G

gk

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html;
charset=iso-8859-1">
<title>Untitled Document</title>
</head>

<body>
<form name="form1" method="post" action="">
<p>&nbsp;</p>
<p>&nbsp;</p>
<table width="430" border="1">
<tr>
<td width="59" height="34">r1</td>
<td width="59">r2</td>
<td width="290"> value </td>
</tr>
<tr>
<td height="37">abcd</td>
<td>efgh</td>
<td>123</td>
</tr>
<tr>
<td height="43">asswe</td>
<td>rtgh</td>
<td>345</td>
</tr>
</table>
<p>&nbsp;</p>
</form>
</body>
</html>

can i duplicate this table 5 times in my page via javascript ? how ?
 
J

Joshie Surber

can i duplicate this table 5 times in my page via javascript ? how ?

form = document.forms[0];
table = form.getElementsByTagName('table')[0];
for (i=0;i<5;i++) {
form.appendChild(table.cloneNode(true));
}
 
G

gk

i am sending XML...

var xml ==<< feedind xml data in every 10 secs interval upto for 50
secs.

// get the XML and parse it.

put the data into the table. so we'll shave 5 tables this way after 50
secs.

you have shouwn how to duplicate the table. but i also want to know how
to set the data .

i need it for dynamic page updation.
 
J

Joshie Surber

you have shouwn how to duplicate the table. but i also want to know how
to set the data .

Much trickier then :)
// Use XMLHTTPRequest, i will call the object http
// and the elements within that signify tr groups <row>
xml = http.returnedXML;
rows = xml.getElementsByTagName('row');
form = document.forms[0];
table = document.createElement('table);
form.appendChild(table);
for (i=0;i<rows.length;i++) {
tr = document.createElement('tr');
table.appendChild(tr);
cells = row.childNodes;
for (j=0;j<cells.length;j++) {
td = document.createElement('td');
tr.appendChild(td);
txt = document.createTextNode(cells.firstChild.nodeValue);
td.appendChild(txt);
}
}

You will have to clean this up a bit to work with your data structures,
of course. Hope it helps.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,432
Messages
2,571,680
Members
48,796
Latest member
Greg L.

Latest Threads

Top