Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:

Ohhhhh gracious ones,

I am trying to use labels in a CGI form. Is this correct? When I view the html, I do not see the labels working. Can you tell me exactly what should be done?

use CGI; $query = new CGI; @letters=("a", "b", "c"); %labels=('1=>a', '2=>b', '3=>c'); print $query->header(-title=>'some letters & labels'), $query->start_html('Welcome to letters'), $query->h1('Welcome letters'), $query->h3("Please select the what you would like to"), $query->p, $query->checkbox_group(-name=>'avletters', -values=>\@letters, -labels=>\%labels), $query->p, ...

Replies are listed 'Best First'.
Re: label usage
by bm (Hermit) on Aug 18, 2003 at 16:33 UTC
    Try changing
    %labels=('1=>a', '2=>b', '3=>c');
    to
    %labels =( 1=>'a', 2=>'b', 3=>'c');
    Also, I recommend turning on warnings and strict.
    --
    bm
      thanks .. it works ... but from within my script, how can I determine which selections were made by the user?
        use CGI; my $cgi = new CGI; my @letters = $cgi->param('avletters'); print "The user selected: "; print "$_\n" foreach(@letters);