Everything Else

HTML Forms

Hi all.

I have a problem I'm having difficulties solving.

I have an HTML page with a table, where every row on the table is a form.
At the end of each row I have a submit button.

The problem is this, I want to combine all the forms into one, so I can have one submit button, *AND*, I have to do it in HTML only, ie, no javaScript or anything else.

Anyone know of a way I can combine multiple forms into one?
Man is the only animal smart enough to build the Empire State Building, and the only one stupid enough to jump off it.
Seems silly, but why not put the table inside the <form> tag? You can then either have 1 submit button or 1 per line and then do server-side parsing to let the user know more data is needed (or not, thinking like an online order form). The only thing is I'm assuming you can use HTML 4? If you just didn't think of this sorry, but having to use forms only inside of tables seems like a Netscape 3.0 support decision or something to me.
There are a number of ways I could have done this, all of which would have been vastly superior to the way it is now. The reality is, that this code is very old legacy code that I've inherited. I uses python cgi, along with HTMLgen to generate pages.

Initially it had very limited functionality, but now, it is to be extended considerably. Hence my dilemma. I have a page with a table, and several rows, all of which contain a single form. I have a checkbox for each row (ie each form) and I want to be able to submit all checked/selected rows with one button.

So yes dude, it is silly, but that's the situation I'm in.

I've been told it is possible, but CGI is not my forte. Hopefully someone out there could steer me in the right direction.
And no, I can't refactor or start again, in case you were wondering. ;-)
Man is the only animal smart enough to build the Empire State Building, and the only one stupid enough to jump off it.
Using pure HTML 4.0 and CGI I'm 99% sure its not possible. I mean if you have multiple forms per page, and submit one, does the server get any info on the other form's attributes? No, its like they're not even there. This is an HTML issue, not a server-side issue. If you can go XML 2.0, XForms lets you do data binding, so two Xforms can share the same attributes with some work since the document has a singular namespace.

If you have to stay HTML, a hack would be to shadow every form's input elements in every other form and use Javascript to toggle all the hidden elements when one real element is toggled. You may be able to accomplish the same via CSS 2.0+ since CSS lets you toggle names elements properties - this is how you do CSS only rollovers and menus, essentially you add text to a hidden element that is sent, then parse it on the server.

Honestly, though, I think it would an order of magnitude easier to just put them all in one form even if it means modifying the legacy code. I mean how hard it is to add a server side variable to not echo the <form></form> tags per line (I'm assuming your code generates each HTML form and checkbox via a function in a template.) and stick one around the whole nested table structure. Maybe a few lines to change the naming scheme, and you're done as each submit now submits the whole form.
tillin9 wrote: Honestly, though, I think it would an order of magnitude easier to just put them all in one form even if it means modifying the legacy code. I mean how hard it is to add a server side variable to not echo the <form></form> tags per line (I'm assuming your code generates each HTML form and checkbox via a function in a template.) and stick one around the whole nested table structure. Maybe a few lines to change the naming scheme, and you're done as each submit now submits the whole form.


I think this is the way to go. Generate a single form out of all forms in the table. Trouble is, how to implement it. :oops:
Man is the only animal smart enough to build the Empire State Building, and the only one stupid enough to jump off it.