Greetings Monks,

I would like some help please with maintaining form state using HTML::Template.

My efforts thus far have been unspectacular to say the least. Maintaining the state with checkboxes is easy but when it comes to dropdown menus it has become tricky. With the dropdowns it easy to generate using my script like:

sub StateDrop { my $state = $q->param('state'); my @states = ("1", "2", "3", "4", "5", "6"); my $menu .= qq"<SELECT NAME="state">\n"; foreach my $x (@states) { $menu .= $x eq $state ? "<option selected>$x<\/OPTION>" : "<OPTION>$x< +\/OPTION>"; } $menu .= "<\/SELECT>"; return $menu; }
I then place that in my Template file via its param method.
But that defeats the purpose of using a Template file. If a change needs to be made then I need to edit the script its self.
Is there a way to this so that it adapts no matter what is in the dropdown menu?
Thanks for any help.


In reply to Maintaining form state with HTML::Template by dwiz

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.