html - Perl CGI - Picking Radio Values for Specificity -
i've got little perl cgi quiz working on, i'm stuck on it. html code follows:
<p class="question"><br>1. answer number 1 </p> <ul class="answers"> <input type="radio" name="q1" value="a" id="q1a"><label for="q1a">1912</label><br/> <input type="radio" name="q1" value="b" id="q1b"><label for="q1b">1922</label><br/> <input type="radio" name="q1" value="c" id="q1c"><label for="q1c">1925</label><br/> <input type="radio" name="q1" value="d" id="q1d"><label for="q1d">summer of '69</label><br/> </ul>
the cgi program picking name radio button parameter value. perl code follows:
if ( param("q1") eq undef ) { $an1 = 0; $winner = 0; print <<"big"; <h1>you didn't enter right answer</h1> big } else { print <<"big"; <h1>you entered right answer</h1> big }
at point, entered right answer if check of radio boxes.
is there way can specify value plucks radio, a
or b
or c
or d
parameter, or doing wrong altogether?
please, refer cgi documentation details on how process radio group. give example:
my $cgi = cgi->new; $value = $cgi->param('q1'); if ($value eq 'a') { #correct answer } else { # incorrect answer }
also, eq
string comparison operator, don't use test undef
. perl has defined
function this.
Comments
Post a Comment