Monastic Monks,

Imagine you have a user sign-up form in html. Name, address, etc.

But now you want to have a single form with input fields for 50 users at a time. 50 name fields , 50 address fields, etc. You'll be dynamically generating the form from a Perl script and TK.

You'll be processing the form with cgi.pm to store it all in a db.

What's a good strategy for setting up the form names that cgi.pm can most effectively exploit?

For example, you could name all the Name fields "name_x", where x is indexed from 1 to 50, and then for processing do something like:

$query = new CGI; @form_field_names = $query->param; foreach $field_num_pair (@form_field_names) { ($field, $index) = split(/_/, $field_num_pair); $form_values{$index}{$field} = $query->param($field_num_pair); }

But I can't help thinking there must be something more elegant that can be done in the structure of the html form to distinguish the users and that can be used more easily by cgi.pm. For example, using both name and ID tags on form elements if cgi.pm picks them up seprately (Except I don't think all browsers send the ID)

Thanks.




Forget that fear of gravity,
Get a little savagery in your life.

In reply to Strategy to name/process many similar form fields with cgi.pm? by punch_card_don

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.