473,387 Members | 1,766 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,387 software developers and data experts.

Help Required in Java Script

I have a Javascript function, which changes a text field of a form into a select field. Following is the function

function changeStateField()
{

var myForm = document.getElementsByTagName("form")[0];

alert(myForm.stateId.value);
myForm.removeChild(myForm.stateId);

var stateSelect = document.createElement("select");
stateSelect.setAttribute("stateId2", "stateId");
myForm.insertBefore(stateSelect, myForm.countyId);
}

Function displays the correct value in alert. but on line 3
myForm.removeChild(myForm.stateId);
it gives following error. I am using Firefox.

Error: uncaught exception: [Exception... "Node was not found" code: "8" nsresult: "0x80530008 (NS_ERROR_DOM_NOT_FOUND_ERR)" location: "http://localhost:8080/APP/premiseCatalog.do Line: 245"]

Your help will be greately appreciated.

Regards,
Naeem.
Nov 21 '06 #1
2 1885
I have a Javascript function, which changes a text field of a form into a select field. Following is the function

function changeStateField()
{

var myForm = document.getElementsByTagName("form")[0];

alert(myForm.stateId.value);
myForm.removeChild(myForm.stateId);

var stateSelect = document.createElement("select");
stateSelect.setAttribute("stateId2", "stateId");
myForm.insertBefore(stateSelect, myForm.countyId);
}

Function displays the correct value in alert. but on line 3
myForm.removeChild(myForm.stateId);
it gives following error. I am using Firefox.

Error: uncaught exception: [Exception... "Node was not found" code: "8" nsresult: "0x80530008 (NS_ERROR_DOM_NOT_FOUND_ERR)" location: "http://localhost:8080/APP/premiseCatalog.do Line: 245"]

Your help will be greately appreciated.

Regards,
Naeem.
try

Expand|Select|Wrap|Line Numbers
  1. var txt = document.getElementById("stateId");
  2. myForm.removeChild(txt);
  3.  
It would help if you also posted a relevant piece of the markup.

Tim S.
Nov 21 '06 #2
try

Expand|Select|Wrap|Line Numbers
  1. var txt = document.getElementById("stateId");
  2. myForm.removeChild(txt);
  3.  
It would help if you also posted a relevant piece of the markup.

Tim S.
Doh!

Expand|Select|Wrap|Line Numbers
  1. var txt = document.getElementById("stateId");
  2. txt.parentNode.removeChild(txt);
  3.  
stateId is probably a descendant, but not a child, of the form element.

Tim S.
Nov 21 '06 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

3
by: Hemant | last post by:
Hi all, I am very new to this HTML/JAVA environment. I am having some doubts please answer them ASAP. I want to run an executable from the browser iteself, without "Save" or "Open" and "Security...
8
by: Johnny Knoxville | last post by:
I've added a favicon to my site (http://lazyape.filetap.com/) which works fine if you add the site to favourites the normal way, but I have some JavaScript code on a couple of pages with a link,...
6
by: mike | last post by:
Hello, After trying to validate this page for a couple of days now I was wondering if someone might be able to help me out. Below is a list of snippets where I am having the errors. 1. Line 334,...
8
by: DKM | last post by:
Here are the source code files to a Java applet that utilizes LiveConnect to communicate with Javascript, and the HTML file. The thing works both in IE 6.0 and FireFox 1.4. but with some...
5
by: Dennis Fazekas | last post by:
Greetings, I am creating a web form which will all the user to add an unlimited number of email addresses. Basically I have 3 buttons, "Add Another Email", "-" to remove, and a "Save" button....
36
by: aljamala | last post by:
Hi, I keep getting this warning on a page, but I do not know what the problem is...does anyone have an idea about what could be wrong? line 88 column 7 - Warning: missing </formbefore <td> it...
0
by: gunimpi | last post by:
http://www.vbforums.com/showthread.php?p=2745431#post2745431 ******************************************************** VB6 OR VBA & Webbrowser DOM Tiny $50 Mini Project Programmer help wanted...
1
by: slavisa | last post by:
Hi, i have a form and i use cgi script to email the results back to me. I have a javascript in there already that checks if the required fields are filled when you click submit and if they are not...
1
by: AR123 | last post by:
Hi I want to set up a rotating banner. Not sure how to incorporate my rotating banner code into the code below. I want the rotating banner to be the main feature image? This is set up in...
1
by: HarishAdea | last post by:
Hi, I am trying to run the JAVA pgm, but it is giving error as "selection does not contain a main type". The filename is "ScoreLeadSummary.java" when i try to run it or debug,it gives the pop...
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
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
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...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

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.