could someone please tell me how can i determine what was the user’s selection given a drop-down menu in the following piece of code ? what am i doing wrong ?
#!/usr/bin/perl -wT
use strict ;
use warnings ;
use CGI ;
use CGI::Carp qw(warningsToBrowser fatalsToBrowser) ;
my $cgi = new CGI ;
print $cgi->header(-type=>"text/html", -charset=>"utf-8") ;
print $cgi->start_html(-title=>"Data Analysis | hellas online") ;
my %labels = ( "yes" => "For Sure!",
"no" => "Not for me.",
"maybe" => "Maybe So." ) ;
print $cgi->popup_menu( -name => "your_answer",
-values => ["yes", "no", "maybe"],
-default => "yes",
-labels => \%labels ) ;
my @selected = $cgi->param("your_answer") ;
foreach my $i (@selected)
{
print $cgi->$i."\n" ;
}
print $cgi->end_html ;
the … print $cgi->$i.”\n” ; … statement does not display anything ?!
thank you.
You never create a form, so the value of the popup_menu can never be submitted. You need to put your form controls inside a form.
$cgi->paramwill have data to fetch only after the form data has been submitted (you’ll need a submit button too) back to the server from the browser.