If you create 5 copies of a form element with the same name CGI.pm will return the contents of all occurances of the
that fieldname as an array of the values in the order they were specified.

Update
MidLifeXis has a valid point concerning the order in which the values will be returned. So if the numbers are necessary to specify some type of ordering or precedence go with this revelation

This will simplify your code immensely when you need to drop back to 3 floor plans or increase to 7 floor plans.

In your template:
[% FOREACH s = [ 1 .. 5 ] %] <tr> <td> Floor Plan Name </td> <td colspan='3'> [% mycgi.textfield( '-name' => floorplan_name, '-size' => '50', '-default' => THIS_PAGE.$IDX.floorplan_na +me ) %] </td> </tr> [% END %]
In your form processing cgi:
my $q = CGI->new; my @floorplans = $CGI->param('floorplan_name'); # How many plans arrived? my $num_plans = @floorplans; # Looping over my plans foreach my $plan ( @floorplans ) { &do_the_plan( $plan ) }
--
Clayton aka "Tex"

In reply to You don't even need to do that (was Re: Template::Toolkit: better way to generate variable names?) by clscott
in thread Template::Toolkit: better way to generate variable names? by geektron

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.