473,385 Members | 1,392 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Removing a form using JavaScript+DOM

Hi.

I've got this HTML page:

------------------------
<HTML>
<HEAD>
<TITLE>Blah</TITLE>
</HEAD>
<form id="foo"><input type="text"></form>
<BODY>
HELLO<br>
</BODY>
</HTML>
-----------------------

and I want to remove 'foo' form.

I'm trying with:
---------
document.removeChild(document.getElementById('foo' ));
---------

but I get this error message:
---------
Error: uncaught exception: [Exception... "Node was not found" code:
"8"
nsresult: "0x80530008 (NS_ERROR_DOM_NOT_FOUND_ERR)"
location: "mypage.html Line: 91"]
-----------

Any suggestion? Thank you very much

Aug 15 '05 #1
2 15806


fr**********@usa.com wrote:

<form id="foo"><input type="text"></form> and I want to remove 'foo' form.

I'm trying with:
---------
document.removeChild(document.getElementById('foo' ));


In the W3C DOM if you want to remove a node you call removeChild on the
parent node so you need
var formElement = document.getElementById('foo');
if (formElement && formElement.parentNode &&
formElement.parentNode.removeChild) {
formElement.parentNode.removeChild(formElement);
}

--

Martin Honnen
http://JavaScript.FAQTs.com/
Aug 15 '05 #2
ASM
fr**********@usa.com wrote:
<form id="foo"><input type="text"></form>
<BODY>
put your form in the body please
and I want to remove 'foo' form.

I'm trying with:
---------
document.removeChild(document.getElementById('foo' ));


try :
document.body.removeChild(document.getElementById( 'foo'));
or
document.getElementsByTagName('BODY')[0].removeChild(document.getElementById('foo'));
--
Stephane Moriaux et son [moins] vieux Mac
Aug 15 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
by: Jeff T. | last post by:
All, Is there any way to access a separate IE 6.0 browser process via the Javascript DOM ? For example, open IE once. Open IE again (not using File->New). Can the second IE browser/process...
2
by: Raghuram Banda | last post by:
Hi There, Can any one help me, in how to create a set of radio buttons in IE using JavaScript DOM. Thanks in advance Raghuram Banda
1
by: Raghuram Banda | last post by:
Hi All, Can any one help me how to create a HIDDEN element using JavaScript (DOM) dynamically The following codes works fine with IE but not in Netscape currentElement =...
1
by: MQ | last post by:
I have been trying to insert a col tag using DOM but I can't seem to make it work. In the following script I create a table with rows and columsn. I tried to modify the column style, but doesn't...
3
by: Reinhold Schrecker | last post by:
Hi there, I am trying to generate a dynamic menu with JavaScript/DOM and have problems to set the onclick-attribute for my <a>-elements. The following code works fine in Opera and Mozilla but...
4
by: Michel Verhagen | last post by:
Hi, I want to create a DTD in an XML file in memory. The XML file is created using the DOM in C#. I am new to all this, but couldn't find anything about creating DTD's using the DOM (well, I...
2
by: Reinhold Schrecker | last post by:
Hi, I am trying to generate a pulldown-menu with JavaScript/DOM: The following Code works fine with Opera an Mozilla but in the IE the width of the select element is too short: ...
2
by: kaustubh.deo | last post by:
Hello, Need your valuable inputs for this scenario. Any pointers would be helpful. I have large data set (few 100s of MB or sometimes may even go up to GB). I populate a DOM tree using this...
3
by: SM | last post by:
Hello, Im trying to access elements in my XML file using the JavaScript DOM but i'm not sure how. I use AJAX to access the XML and then use the responseXML property to access the XML file data. I...
1
by: swetha123 | last post by:
hello , I need to alert the value entered in the text box,which is in TD cell, using DOM can any one tell how please here is the code with out a text box which is working <html> <head> ...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.