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

I am in process of creating a web form. I am uisng CGI module.

$q->popup_menu(-name=>'Summary', -values=>['black','brown','red','yellow'], -default=>'red')

Syntax for defining lables is a follows

$q->popup_menu(-name=>'Summary', -values=>['black','brown','red','yellow'], -default=>'red',\%lables)

Using above code I have created a combo box without lables.But I am not able to define label for the field following the above syntax adn also no error message is thrown

Replies are listed 'Best First'.
Re: Defining Lable for a field
by almut (Canon) on Apr 21, 2009 at 13:47 UTC

    I think you want

    use CGI; my $q = CGI->new(); my %labels = ('black' => 'Black', 'brown' => 'Brown', 'red' => 'Red', 'yellow' => 'Yellow'); print $q->popup_menu( -name => 'Summary', -values => ['black','brown','red','yellow'], -default => 'red', -labels => \%labels ); # alternatively, without named params print $q->popup_menu( 'Summary', ['black','brown','red','yellow'], 'red', \%labels );

      No i wanted to assign lable for the controls

        Which controls?

        The above snippet creates the following output, which looks just fine to me:

        <select name="Summary" > <option value="black">Black</option> <option value="brown">Brown</option> <option selected="selected" value="red">Red</option> <option value="yellow">Yellow</option> </select>