michellem has asked for the wisdom of the Perl Monks concerning the following question:
And then I go on to print the form...sub print_form() { my %field_ref; my $field_ref = shift; #first, set the params my $q = new CGI(""); my %real_fields; while (my $key = each %$field_ref) { $real_fields{$key} = $field_ref->{$key}; my $index = index $configs{checkboxes},$key; if ($index != -1) { my @check_array = split(',',$real_fields{$key}); $q->param(-name=>"$key", -value=>"\@check_array"); } else { $q->param(-name=>"$key", -value=>"$real_fields{$key}"); } }
(@params is an array that holds the form parameters for each form element)elsif ($type =~ /check/) { my %hash = (); $type =~ s/check/checkbox/; (my $values, my $labels) = split (':',$params[0]); my @checks_list = split (';',$values); my @clabels_list = split (';',$labels); @hash{@checks_list} = @clabels_list; foreach (keys %hash) { print checkbox(-name=>"$name", -value=>$_, -label=>"$hash{$_}" +); } print br();
Any advice? The checkboxes themselves print out fine, but nothing is checked. When I check off things on the form, that data makes it into the database just fine.
Thanks!!
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: CGI Checkboxes
by davorg (Chancellor) on Oct 26, 2001 at 18:51 UTC | |
by michellem (Friar) on Oct 26, 2001 at 18:52 UTC | |
by davorg (Chancellor) on Oct 26, 2001 at 19:13 UTC | |
by Sidhekin (Priest) on Oct 26, 2001 at 19:41 UTC | |
by michellem (Friar) on Oct 26, 2001 at 19:57 UTC | |
by michellem (Friar) on Oct 26, 2001 at 19:26 UTC | |
by michellem (Friar) on Oct 26, 2001 at 21:23 UTC | |
|
Re: CGI Checkboxes
by miyagawa (Chaplain) on Oct 26, 2001 at 18:51 UTC | |
by michellem (Friar) on Oct 26, 2001 at 18:53 UTC | |
|
First Normal Form (was Re: CGI Checkboxes)
by mandog (Curate) on Oct 26, 2001 at 20:16 UTC | |
by michellem (Friar) on Oct 26, 2001 at 20:26 UTC | |
by reclaw (Curate) on Oct 27, 2001 at 23:14 UTC | |
by michellem (Friar) on Nov 01, 2001 at 04:18 UTC |