Browsers and dynamically-generated form fields
A month ago, I was working on some AJAX stuff on vTiger. I was generating some form elements with JavaScript with appendChild() function. The elements appeared fine but when testing the form with some data and submitting, the generated form fields passed on data on neither POST nor GET.
The problem was with Firefox, Opera and Konquerer but not on Internet Explorer!!
After doing some checks and re-building the whole thing I found out it's a problem with nesting page elements, for example when you put start a FORM tag inside a DIV then you close the DIV then finally close the tag.
When you generate any form fields and attach them to the DIV or the FORM with JavaScript, these elements won't send any variables like other form data. They will only do this with the form being nested correctly even if the rest of the page is a mess.
It seems like IE forgives you this mistake for the sake of being his buddy, while Firefox and other guys actually take it too serious (j/k).
I hope this helps anyone.



I've been banging my head for a solution to this problem for days. Upon reading your post, I ripped out all the formatting and tables on my page and presto. Workie. Sloppy nesting was the problem.
Thanks dude.
- reply
Submitted by Anonymous on 4 September 2006 - 2:00pm.I've found this in areas where tags where not even improperly nested. For instance, when I've hidden the form tag in between the tr and td tags of a table. I will do this to prevent a page break, but the nesting is still proper. I've found firefox will not attach the new dynamically generated form elements to the post or get variables.
- reply
Submitted by Adam Schroeder (not verified) on 8 January 2007 - 10:02pm.As far as I know, putting FORM tag in TR isn't XHTML compliant. It could be HTML 4.01 but not XHTML at all. Thus having your page DTDed as XHTML will surely break Firefox's rendering.
I think you better try to put the whole TABLE inside the FORM tag and see.
HTH
Omar
- reply
Submitted by Omar on 10 January 2007 - 10:25am.I can't even dare to start solving my problem, i am not so good at all this and i have to rely on my friends help. Also I will show him these comments may be they can get useful. Ohh...computer problems take my breath away.
- reply
Submitted by sofa tables (not verified) on 25 May 2007 - 6:31am.I have the same problem with firefox and post with a dynamically-generated combobox and I didn't found a solution yet for my problem. I attached the combobox to a div first and then to a td. I ripped out almost everything from my form and still doesn't work. I've searched on google for a few days and I didn't find a solution.
Could you send me in email a working example of this?
- reply
Submitted by Ady (not verified) on 29 October 2006 - 6:28pm.Ady,
Please create a forum post with your problem with the HTML code to be able to help you.
Omar Abdel-Wahab
- reply
Submitted by Omar on 29 October 2006 - 9:52pm.Thanks a lot. I was about to rip my head off lookin for a solution for this. Thanks.
- reply
Submitted by Diego Sanchez (not verified) on 26 February 2007 - 6:26pm.thank you!!!
i only wished that google would've given this page a higher rank!!!!
- reply
Submitted by dan carlson (not verified) on 5 March 2007 - 5:27pm.You save my day ... :)
- reply
Submitted by Mikolaj (not verified) on 23 March 2007 - 11:20am.Dude - thanks for posting this! I was ready to throw down my laptop and stomp on it! In my situation I needed to move my 'form' tags and hidden form fields out from in-between the table and tr tags (this was the 'old school' way to do it to avoid the extra padding the browsers would add for the form tag).
Thanks again!
-Frank
- reply
Submitted by Frank C (not verified) on 13 April 2007 - 7:03am.I was having a major problem getting my forms to pass the data from spans populated with ajax in firefox. I have had a habit of putting my opening and closing form tags inside of the opening and closing table tags. Once I moved them outside, Presto! the form worked just fine.
- reply
Submitted by jfonline (not verified) on 4 June 2007 - 4:42pm.I've seen a few more confused summaries of this problem around the web but your post made it obvious what was wrong with my code - hurrah!
- reply
Submitted by Matthew (not verified) on 8 June 2007 - 12:32am.big thanks for post
I was about to rip my head off lookin for a good solution for this
- reply
Submitted by Anonymous on 23 July 2008 - 2:37pm.Post new comment