473,654 Members | 3,308 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

appendChild() problem in IE / Firefox

1 New Member
Hi,

I am using this code to add hidden fields dynamically before the form submission.

function transfer(action Value,tms)
{
var formElement = document.forms['agreementForm'];
document.forms['agreementForm'].action = actionValue;
var newField = document.create Element("input" );
newField.type = "hidden";
newField.name = "lastUpdateTms" ;
newField.value = tms;
document.forms['agreementForm'].appendChild(ne wField);
formElement.sub mit();
}

This goes thru well in FireFox but IE does not let me use line
document.forms['agreementForm'].appendChild(ne wField); as it is. Not able to figure out what is the problem. Please suggest.
May 8 '07 #1
1 3366
sumittyagi
202 Recognized Expert New Member
Hi,

I am using this code to add hidden fields dynamically before the form submission.

function transfer(action Value,tms)
{
var formElement = document.forms['agreementForm'];
document.forms['agreementForm'].action = actionValue;
var newField = document.create Element("input" );
newField.type = "hidden";
newField.name = "lastUpdateTms" ;
newField.value = tms;
document.forms['agreementForm'].appendChild(ne wField);
formElement.sub mit();
}

This goes thru well in FireFox but IE does not let me use line
document.forms['agreementForm'].appendChild(ne wField); as it is. Not able to figure out what is the problem. Please suggest.
on my system it is running fine.
there might be any other problem in your code.
I ran it this way:
Expand|Select|Wrap|Line Numbers
  1. <HTML>
  2. <HEAD>
  3. <script>
  4. function transfer(actionValue,tms)
  5. {
  6. var formElement = document.forms['agreementForm'];
  7. document.forms['agreementForm'].action = actionValue;
  8. var newField = document.createElement("input");
  9. newField.type = "hidden";
  10. newField.name = "lastUpdateTms";
  11. newField.value = tms;
  12. alert('before:' + formElement.childNodes.length);
  13. document.forms['agreementForm'].appendChild(newField);
  14. alert('after:' + formElement.childNodes.length);
  15. //formElement.submit();
  16. }
  17. </script>
  18. </HEAD>
  19.  
  20. <BODY>
  21. <form name="agreementForm">
  22. <input type="button" value="click here" onclick="transfer('abc','hidden23')">
  23. </form>
  24. </BODY>
  25. </HTML>
  26.  
it gave alerts:
before: 2
after: 3

check in your code if you have used any keyword as variable or control name, because these type of uncertain problems apper in that case only.

or paste other parts of you code as well, I will try to see the problem.
May 8 '07 #2

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

Similar topics

12
2070
by: Keith Page | last post by:
I have a page that changes a list of checkboxes based on what city you select, however when i insert the new nodes the values are not submitted when the boxes are checked and form is sent, its like they are not hooked to the form properly. Any help would be appritiated JAVASCRIPT ///
6
3685
by: skubik | last post by:
Hi everyone. I'm attempting to write a Javascript that will create a form within a brand-new document in a specific frame of a frameset. The problem is that I can create the form and input element using createElement(), but when I go to append the form element into the new document, the script halts and I get the following error in my Javascript Console (Firefox 1.0): __tmp_newDoc.body has no properties.
1
4953
by: Ryan Stewart | last post by:
If you don't want to read this post because of its length, I understand. I've spent two and a half days on this problem and have a good deal of information to relate. And this is kind of a long shot, but I'm just hoping someone here has experienced a similar problem and has a better idea of what's going on than I do. First, I've tested this in IE 6.0, Netscape 7.2, Mozilla 1.75, and Firefox 1.0. It works fine in IE (even though I was...
2
1450
by: Stewart | last post by:
Originally posted in comp.lang.javascript: Newsgroups: comp.lang.javascript From: "Stewart" Date: 23 Aug 2005 02:50:04 -0700 Local: Tues, Aug 23 2005 10:50 am Subject: FireFox, RemoveChild, AppendChild, making width grow? Hi,
4
2215
by: matty | last post by:
Hello, here is an example of what is driving me totally crazy. This example will show that the first call to "doit()" will print 30 times the image with only one call to the server. Then I have a timeout and call doit() again, and this time, it downloads the picture 30 times!!!! It doesn't even time to finish downloading the pictures before the next timeout kicks off and if I let it go for a minute or two i have like 300 calls to...
2
10484
by: Christina | last post by:
I have 2 list boxes - one to fill the second one based on the selection, or move all items. You can remove the selection (or all items) from the second one to place it back in the first one. I expanded my horizons and thought to use script based on the js node operation appendChild(). It seemed so clean and easy to follow. Works beautifully in IE, but Firefox sees the value for a nanosecond but doesn't put it in the box. This is the...
1
6026
by: Derek Basch | last post by:
I spent several hours struggling with dynamic form fields added with appendChild or innerHTML not POSTing on submit in Firefox. The only way I found to make it work is to append any created fields to a DIV within the form. Here is an example I store from another post. I hope this helps someone. <html lang="en"> <head> <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
1
1642
by: cleancode | last post by:
Suppose I have a Parent DIV element and I dynamically add DIV's inside it (Children) using appendChild. It works . But if I were to now set the visibility of the Parent DIV to Invisible, although the parent DIV gets hidden, the child DIV's are still visible. This happens in Firefox. How do I also cause the child DIV's to become invisible , when I make the parent DIV invisible ? Any ideas,Sugestions, or Advice on how I can overcome this...
2
2241
by: vsanjit | last post by:
Hi all, I've been trying to create a table dynamically upon the generation of en event using the appendChild method in Javascript. This seems to work fine in Firefox, but not in IE7. There's also no error message from IE. I'm new to these routines. Could someone shed some light on where I could be going wrong? Here's the code: <html> <head> <script type='text/javascript'> function makeTable() {
0
8379
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 usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8709
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8494
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 most users, this new feature is actually very convenient. If you want to control the update process,...
0
8596
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7309
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 launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5627
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 into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4150
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 the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
2719
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1924
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.