Processing multiple forms in a cgi script

Grant Edwards invalid at invalid.invalid
Fri Feb 19 13:29:47 EST 2016


On 2016-02-19, Jon Ribbens <jon+usenet at unequivocal.co.uk> wrote:
> On 2016-02-19, Jeremy Leonard <jrmy.lnrd at gmail.com> wrote:
>
>> I have a quick question regarding processing multiple forms. Most
>> of my experience has been where there is just one form so the logic
>> was pretty straight forward for me. My question revolves around how
>> to handle multiple forms. I've seen that you can have an id for
>> each form, but I'm unsure how to process that. Any info or a
>> point/kick in the right direction would be appreciated.
>
> Only one form can be submitted at once.

Unless you do something rather obtuse like using Javascript to
serialize multiple HTML forms into separate JSON objects and then
combine those into a single JSON object and then submit that via an
AJAX call.  [You could use XML instead of JSON, but that'd be even
worse.]

I've no clue _why_ somebody would go to the trouble to do something
like that -- if you know how to stuff like that, then you probably
know better than to actually do it. ;)

If the data on some set of multiple forms is always going to be
submitted together, then just use a single form instead.

If you want to handle multiple different forms _one_at_a_time_ using a
single form handler, then just put a hidden input field on each form
that identifies which one it is.

-- 
Grant Edwards               grant.b.edwards        Yow! Are you selling NYLON
                                  at               OIL WELLS??  If so, we can
                              gmail.com            use TWO DOZEN!!



More information about the Python-list mailing list