473,503 Members | 1,697 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(actionValue,tms)
{
var formElement = document.forms['agreementForm'];
document.forms['agreementForm'].action = actionValue;
var newField = document.createElement("input");
newField.type = "hidden";
newField.name = "lastUpdateTms";
newField.value = tms;
document.forms['agreementForm'].appendChild(newField);
formElement.submit();
}

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

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

function transfer(actionValue,tms)
{
var formElement = document.forms['agreementForm'];
document.forms['agreementForm'].action = actionValue;
var newField = document.createElement("input");
newField.type = "hidden";
newField.name = "lastUpdateTms";
newField.value = tms;
document.forms['agreementForm'].appendChild(newField);
formElement.submit();
}

This goes thru well in FireFox but IE does not let me use line
document.forms['agreementForm'].appendChild(newField); 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
2051
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...
6
3672
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...
1
4935
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...
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,...
4
2209
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...
2
10474
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...
1
5984
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...
1
1626
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...
2
2240
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...
0
7199
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
7074
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
7322
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...
1
6982
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...
0
7451
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...
0
5572
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,...
0
4667
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...
0
3150
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1501
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 ...

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.