in reply to First Normal Form (was Re: CGI Checkboxes)
in thread CGI Checkboxes

mandog writes
You are (apparently) violating the First Normal Form.

Well, yes and no. I understand well the idea of normalizing databases, and use it when I design my own databases. But I'm not writing a specific application for a specific database - I'm writing a generic application to allow people to edit their own database data, using schema and form elements that they have designed. On the web, this generally flat file, not relational (although I'm working on getting this to work for relational databases).

The standard way that checkboxes work is to allow multiple choices within one field. I'm just trying to allow people to work with this standard. If they know something about database atomicity, then they should design their databases accordingly. :-)

  • Comment on Re: First Normal Form (was Re: CGI Checkboxes)

Replies are listed 'Best First'.
Re: Re: First Normal Form (was Re: CGI Checkboxes)
by reclaw (Curate) on Oct 27, 2001 at 23:14 UTC

    I don't know if a working example would help, but here it is anyway:

    #!/perl/bin/perl -w use strict; use CGI; my $query = new CGI; my @checks_list = qw(eenie meenie minie moe); my @check_array = qw(eenie moe); my %hash = ( eenie => 'Eenie', meenie => 'Meenie', minie => 'Minie', moe => 'Moe'); print $query->header(), $query->start_html(), $query->start_form(), $query->checkbox_group( -name => 'group_name', -values => \@checks_list, -default => \@check_array, -labels => \%hash, -rows => 2, -columns => 2), $query->end_form(), $query->end_html();
      Thanks, but I need to use the param function - these checkboxes are defined by data in a database - I can't pre-define them.

      I hate to brute-force it, and not use CGI, which I can do, but I'd rather use CGI. But it's looking grim...

      Update: Here's the brute force code that works:

      elsif ($type =~ /check/) { my $i=0; print "$english:\n"; (my $values, my $labels) = split (':',$params[0]); my @checks_list = split (';',$values); my @clabels_list = split (';',$labels); foreach(@checks_list) { my $index=index $real_fields{$name},$_; if ($index != -1) { print "$clabels_list[$i]<INPUT TYPE=\"checkbox\" N +AME=\"$name\" VALUE=\"$_\" CHECKED>\n"; } else { print "$clabels_list[$i]<INPUT TYPE=\"checkbox\" N +AME=\"$name\" VALUE=\"$_\">\n"; } $i++; } print $q->br(); }

      I'd love it if someone found a way to use the param function of CGI to get this to work!