Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Javascript > Dynamic form fields added with appendChild or innerHTML do not POST on submit in Firefox

Reply
Thread Tools

Dynamic form fields added with appendChild or innerHTML do not POST on submit in Firefox

 
 
Derek Basch
Guest
Posts: n/a
 
      05-23-2007
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">
<title>creating input elements dynamically</title>
<script type="text/javascript">
function addInput () {
var div;
if (document.getElementById) {
div = document.getElementById('hiddenList');
var input;
if (document.createElement && (input =
document.createElement('input'))) {
input.type = 'hidden';
input.name = 'currentDate';
input.defaultValue = input.value = new Date().toString();
div.appendChild(input);
}
}
}

function showQueryString () {
document.write('<p>location.search: ' + location.search + '<\/p>\r
\n');
}

</script>

</head>
<body>
<script type="text/javascript">
showQueryString();
</script>

<form name="form1" action="test.php">
<div id="hiddenList"></div>

<input type="submit" onClick="addInput()">
</form>

</body>
</html>

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Form Submit Dynamic URL, Leave Fields Off Mitchell Fisher Javascript 0 05-27-2007 09:24 PM
Dynamic form fields added with appendChild or innerHTML do not POST on submit in Firefox Derek Basch Javascript 1 05-24-2007 02:59 AM
xhtml, innerHtml, appendChild, and innerHTML. what is the exact proper way to do this with DOM sonic Javascript 5 07-11-2006 08:17 AM
Weird innerHTML/appendChild IE crash nickdevx@hotmail.com Javascript 14 11-07-2005 02:08 AM
innerHTML / Appendchild question Nicolas Van Lancker Javascript 1 05-07-2004 10:36 PM



Advertisments