Linux - SoftwareThis forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
I want to insert a row in a table using Javascript DOM programming. But I get the error mentioned below when I run the below script in Mozilla. Though I am able to appenChild successfully, I am not able to insert the row. If you have any such experience, please help.
<html>
<head>
<script language="javascript1.2">
function insert()
{
newTD=document.createElement("td");
newText=document.createTextNode("inserted node");
newTD.appendChild(newText);
newTR=document.createElement("tr");
newTR.appendChild(newTD);
mytable=document.getElementById("mytable");
oldTR=mytable.getElementsByTagName("tr").item(1);
mytable.insertBefore(newTR,oldTR);
}
</script>
</head>
<body>
<table border="1" id="mytable">
<tr>
<td>Td one row one</td>
<td>td two row one</td>
</tr>
<tr>
<td>Td one row two</td>
<td>td two row two</td>
</tr>
</table>
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.