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.

wicked post Omar

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.

Submitted by Anonymous on 4 September 2006 - 2:00pm.
Firefox bug.

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.

Submitted by Adam Schroeder (not verified) on 8 January 2007 - 10:02pm.
Omar's picture
As far as I know

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

Submitted by Omar on 10 January 2007 - 10:25am.
What if i's something else?

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.

Submitted by sofa tables (not verified) on 25 May 2007 - 6:31am.
The same problem

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?

Submitted by Ady (not verified) on 29 October 2006 - 6:28pm.
Omar's picture
Please post the HTML

Ady,
Please create a forum post with your problem with the HTML code to be able to help you.
Omar Abdel-Wahab

Submitted by Omar on 29 October 2006 - 9:52pm.
Thanks a lot

Thanks a lot. I was about to rip my head off lookin for a solution for this. Thanks.

Submitted by Diego Sanchez (not verified) on 26 February 2007 - 6:26pm.
thank you!!! i only wished

thank you!!!

i only wished that google would've given this page a higher rank!!!!

Submitted by dan carlson (not verified) on 5 March 2007 - 5:27pm.
Thank You a lot

You save my day ... :)

Submitted by Mikolaj (not verified) on 23 March 2007 - 11:20am.
Thanks!

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

Submitted by Frank C (not verified) on 13 April 2007 - 7:03am.
Browsers and dynamically-generated form fields

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.

Submitted by jfonline (not verified) on 4 June 2007 - 4:42pm.
Thanks again :)

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!

Submitted by Matthew (not verified) on 8 June 2007 - 12:32am.
thanks

big thanks for post
I was about to rip my head off lookin for a good solution for this

Submitted by Anonymous on 23 July 2008 - 2:37pm.

Post new comment

The content of this field is kept private and will not be shown publicly.
  • Allowed HTML tags: <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd><p>
  • You may post PHP code. You should include <?php ?> tags.
  • Lines and paragraphs break automatically.
  • Web page addresses and e-mail addresses turn into links automatically.

More information about formatting options