Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #103212 > unrolled thread

Processing multiple forms in a cgi script

Started byJeremy Leonard <jrmy.lnrd@gmail.com>
First post2016-02-19 10:13 -0800
Last post2016-02-19 10:38 -0800
Articles 4 — 3 participants

Back to article view | Back to comp.lang.python


Contents

  Processing multiple forms in a cgi script Jeremy Leonard <jrmy.lnrd@gmail.com> - 2016-02-19 10:13 -0800
    Re: Processing multiple forms in a cgi script Jon Ribbens <jon+usenet@unequivocal.co.uk> - 2016-02-19 18:15 +0000
      Re: Processing multiple forms in a cgi script Grant Edwards <invalid@invalid.invalid> - 2016-02-19 18:29 +0000
      Re: Processing multiple forms in a cgi script Jeremy Leonard <jrmy.lnrd@gmail.com> - 2016-02-19 10:38 -0800

#103212 — Processing multiple forms in a cgi script

FromJeremy Leonard <jrmy.lnrd@gmail.com>
Date2016-02-19 10:13 -0800
SubjectProcessing multiple forms in a cgi script
Message-ID<16807edd-4376-4a36-82a7-3bcff8e86a0a@googlegroups.com>
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.

[toc] | [next] | [standalone]


#103214

FromJon Ribbens <jon+usenet@unequivocal.co.uk>
Date2016-02-19 18:15 +0000
Message-ID<slrnncen3n.16b.jon+usenet@wintry.unequivocal.co.uk>
In reply to#103212
On 2016-02-19, Jeremy Leonard <jrmy.lnrd@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. To identify in your code
which one it was, either make the "action" attribute for each form
point to different URLs, or put a unique "name" attribute on each
submit button, or put an <input type="hidden"> in each form with
a unique name/value.

[toc] | [prev] | [next] | [standalone]


#103215

FromGrant Edwards <invalid@invalid.invalid>
Date2016-02-19 18:29 +0000
Message-ID<na7mur$g7t$1@reader1.panix.com>
In reply to#103214
On 2016-02-19, Jon Ribbens <jon+usenet@unequivocal.co.uk> wrote:
> On 2016-02-19, Jeremy Leonard <jrmy.lnrd@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!!

[toc] | [prev] | [next] | [standalone]


#103218

FromJeremy Leonard <jrmy.lnrd@gmail.com>
Date2016-02-19 10:38 -0800
Message-ID<54ef2615-15a9-406e-8257-d63faac177fb@googlegroups.com>
In reply to#103214
On Friday, February 19, 2016 at 1:18:41 PM UTC-5, Jon Ribbens wrote:
> On 2016-02-19, Jeremy Leonard 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. To identify in your code
> which one it was, either make the "action" attribute for each form
> point to different URLs, or put a unique "name" attribute on each
> submit button, or put an <input type="hidden"> in each form with
> a unique name/value.

Thank you. That helps. The hidden input will be perfect.

[toc] | [prev] | [standalone]


Back to top | Article view | comp.lang.python


csiph-web