LinuxQuestions.org
Review your favorite Linux distribution.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This 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

Reply
 
Search this Thread
Old 02-06-2006, 07:57 AM   #1
tooparam
Member
 
Registered: Nov 2005
Location: India
Distribution: Slackware
Posts: 51

Rep: Reputation: 15
Problem with javascript DOM programming


Hi there

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>

<input type=button value="Insert Before" onclick = 'insert()'>
</body>
</html>

Error: uncaught exception: [Exception... "Node was not found" code: "8" nsresult: "0x80530008 (NS_ERROR_DOM_NOT_FOUND_ERR)" location: "file:///root/LearnDOM/insert2.htm Line: 13"]

In my case line no . 13 is mytable.insertBefore(newTR,oldTR);

Please help me and show me the right direction.
 
Old 02-07-2006, 07:28 AM   #2
Spudley
Member
 
Registered: Mar 2003
Location: Berkshire, England.
Distribution: SuSE 10.0
Posts: 299

Rep: Reputation: 32
I answered a very similar question here on LQ a few days ago. Here's the link:

http://www.linuxquestions.org/questi....php?p=2080048
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
javaScript - DOM, djgerbavore Programming 2 03-03-2005 05:44 AM
lookin for a javascript DOM guru... pld Programming 1 02-17-2005 06:14 PM
Java/Javascript problem????? Jadewolf Linux - Software 2 10-25-2003 08:06 PM
Javascript in Linux problem? BajaNick Linux - Software 5 10-20-2003 01:41 PM
Elinks: javascript problem ashesh Linux - General 1 07-21-2003 03:06 AM


All times are GMT -5. The time now is 03:59 AM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration