Hello:

I have a form where a user could submit data etc.
I have 4 checkboxes
SSD [] PERS [] SS [] CHILD SUP []


Let's say a user checked the SS box and the PERS box.

Now when the user edits the form, I want the same form display and have those two items checked.

How would you do this without big if blocks?

My code:

@ss = split(/,/,$INPUT{'ss'}); foreach $ss (@ss) { if ($ss eq "ss") { print <<EOF; SS: <input type="checkbox" name="ss" value="ss" checked>&nbsp;&nbsp; EOF } elsif ($ss eq "SSD") { print <<EOF; SSD: <input type="checkbox" name="ss" value="ssd" checked>&nbsp;&nbsp +; EOF } elsif ($ss eq "PERS") { print <<EOF; PERS: <input type="checkbox" name="ss" value="pers" checked>&nbsp;&nb +sp; EOF } elsif ($ss eq "childsup") { print <<EOF; <td>CHILD SUP: <input type="checkbox" name="ss" value="childsup" +checked></td> EOF } }

Is there a module or something else that makes it easier to do this?? This is only a part of the form, I also have a field that has 9 checkboxes and that will make the if block even bigger :).
Anthony

In reply to Edit page with checkboxes by perleager

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.