in reply to (jeffa) Re: Edit page with checkboxes
in thread Edit page with checkboxes

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.

Replies are listed 'Best First'.
(jeffa) 3Re: Edit page with checkboxes
by jeffa (Bishop) on Aug 04, 2002 at 22:30 UTC
    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)