Nested forms via AJAX with the same CGI field

I have a situation where I have several forms from multiple databases coming into a single form via AJAX. I have the CGI field ‘Path_Info’ in several of the forms. I need to grab the Path_Info from the top form, or the one that contains all of the other forms. I’m using JQuery to access the value.

In firefox I get the Path_Info field of the top form.

In IE I get the Path_Info field from the last form loaded from the ajax call.

Is there a programmatic way, using javascript, to get the field I want or am I going to need to create a special field with a unique name that can hold the DBPath of the top form?

Subject: Nested forms via AJAX with the same CGI field

Here’s something interesting. Firefox sees only one form element and IE sees two. Taking jQuery out of the equation now:

In Firefox (document.forms[0].Path_Info.length) returns ‘undefined’.

(document.forms[0].Path_Info[document.forms[0].Path_Info.length].value) bombs out.

(document.forms[0].Path_Info.value) gives me the value I’m looking for.

In IE(document.forms[0].Path_Info.length) returns ‘2’.

document.forms[0].Path_Info[document.forms[0].Path_Info.length].value gives me wthe value I’m looking for.

(document.forms[0].Path_Info.value) gives me the value of the most recent form called via AJAX.

Subject: RE: Nested forms via AJAX with the same CGI field

Nested forms are illegal. IE should be crapping out as well, but MS has always gone out of its way to allow bad development practices.

Subject: RE: Nested forms via AJAX with the same CGI field

OK. Actually Firefox works & IE is crapping out.And yes, nested forms was probably not a good idea but that’s what I have to work with and I don’t have time to re-design the app right now but maybe later.

So, for next time, I have an indeterminable number of forms from multiple databases that need to go into one web UI with a tabbed interface. Each tab may contain one or more forms, depending upon the form. I want any given form to be edited independently and the whole page to not refresh when an edit is submitted so the edits happen within an iFrame that pops up in the center of the page. When the edit is submitted, the iFrame is closed and only that form on the UI is updated.

I could have started with a page design element but I felt that I needed access to the CGI variables and other functionality that a form provides.

I could have brought in just the values as XML from each form via AJAX and then dynamically build the form using the DOM but I wanted each form to use a form design element so that they could be brought into other apps developed later.

How else I could have built the UI?

Subject: RE: Nested forms via AJAX with the same CGI field

A Page (or a treat-as-HTML form) would avoid the top-level tag. The problem, then, becomes how to get the CGI stuff, right? There are any number of ways to do that, including using @GetHTTPHeader used to set JS variables directly, using a form as a JavaScript file, letting the individual document update forms bring the CGI values with them (since there’s no “top form”, there is no field conflict) – imagination is the only limit.

Subject: Nested forms: Close the domino tag and start a new one.

Oops, double post.

Subject: Nested forms: Close the domino tag and start a new one.

I ended up adding a closing form tag at the top and an opening form tag at the bottom of the form design element. Then I just removed the first tag using javascript. That means that the form in the top design element will always be the last form in the HTML so I can use form[forms.length-1] to get what I need.

That hack fixed my problem. Obviously this isn’t best practices but it was the best option at that time. I can move everything to a page element later.

Subject: RE: Nested forms via AJAX with the same CGI field

Firefox is ignoring the extra tags, IE sees them. In other words, IE is working with the nested form tags.