473,569 Members | 2,729 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Help Required in Java Script

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

function changeStateFiel d()
{

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

alert(myForm.st ateId.value);
myForm.removeCh ild(myForm.stat eId);

var stateSelect = document.create Element("select ");
stateSelect.set Attribute("stat eId2", "stateId");
myForm.insertBe fore(stateSelec t, myForm.countyId );
}

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

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

Your help will be greately appreciated.

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

function changeStateFiel d()
{

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

alert(myForm.st ateId.value);
myForm.removeCh ild(myForm.stat eId);

var stateSelect = document.create Element("select ");
stateSelect.set Attribute("stat eId2", "stateId");
myForm.insertBe fore(stateSelec t, myForm.countyId );
}

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

Error: uncaught exception: [Exception... "Node was not found" code: "8" nsresult: "0x80530008 (NS_ERROR_DOM_N OT_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
tschaeffer
2 New Member
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
6127
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 Warning" dialog boxes. The code below works perfectly to my requirement. I downloaded this code snippet from the net. But what i didn't understand...
8
4203
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, which when you click it bookmarks the site (much easier). The favicon is never saved if the site is bookmarked this way. Does anyone have any ideas...
6
6317
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, column 13: there is no attribute "SRC" <bgsound src="C:\My Documents\zingwent.mids"> You have used the attribute named above in your document, but...
8
3368
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 problems. IE crashes when one refreshes the page or leave the page. This happens only after calling the Java method more than once. It does not crash if...
5
3718
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. When the user clicks the "Add another email" it will call a client side JavaScript function, add_email, which will dynamically add a new set of...
36
3084
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 highlights this line: <form name="frmCurrency" action="" method="post"> Page source....
0
5542
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 ******************************************************** For this teeny job, please refer to: http://feeds.reddit.com/feed/8fu/?o=25
1
2871
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 there is a pop up that says these fields are not filled in. When i fill them all in and click submit it works great but it takes me to like...
1
2558
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 mediasurface My code is: <!-- start page container --> <div id="pageContainer"> <!-- start middle content area --> <div id="genericMiddle">
1
13292
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 up as "selection does not contain a main type" Please help me out in resolving the above issue to run the .java file. I am facing same issue with...
0
7694
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7609
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
1
7666
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
6278
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
1
5504
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
5217
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3651
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
0
3636
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
936
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

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.