in reply to Edit page with checkboxes

You want CGI.pm:
use strict; use CGI qw(:standard); my @box = (qw(SSD PERS SS), 'CHILD SUP'); print header, start_html, start_form, checkbox_group( -name=>'type', -values=>\@box, ), p(submit('Go')), end_form, ; if (param('Go')) { print p(hr), 'You picked:', ul(li[param('type')]), ; } print end_html;

jeffa

L-LL-L--L-LL-L--L-LL-L--
-R--R-RR-R--R-RR-R--R-RR
B--B--B--B--B--B--B--B--
H---H---H---H---H---H---
(the triplet paradiddle with high-hat)

Replies are listed 'Best First'.
Re: (jeffa) Re: Edit page with checkboxes
by Jaap (Curate) on Aug 04, 2002 at 22:09 UTC
    I disagree. IT isn't really a solution to the problem either.
    You might want to use the ? : construction. like
    true ? print " selected" : print "";
    I am sure that there are monks here who can explain this better but this is the general idea.
      I think that was a fine solution to the problem. Why not use CGI.pm? And sure, there are many ways to tackle this problem - here is another that utilizes your ternary suggestion:
      use strict; my @ss = ('SSD','PERS','SS','CHILD SUP'); my %checked = map {$_ => 1} ('SSD','PERS'); foreach my $ss (@ss) { print qq|<input type="checkbox" name="ss" value="$ss"|, $checked{$ss} ? ' selected' : '', ">\n" ; }
      UPDATE:
      Actually, @checked should be populated with something like the original:
      my %checked = map {$_ => 1} split(/,/,$INPUT{'ss'})
      But that point is moot (mu?) - use CGI.pm to handle form processing.

      jeffa

      L-LL-L--L-LL-L--L-LL-L--
      -R--R-RR-R--R-RR-R--R-RR
      B--B--B--B--B--B--B--B--
      H---H---H---H---H---H---
      (the triplet paradiddle with high-hat)