【发布时间】:2016-07-03 22:13:42
【问题描述】:
我正在做一个关于 Perl CGI 的小测验,但我完全被它困住了。我的 HTML 代码如下:
<p class="question"><br>1. The answer is 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>
CGI 程序从单选按钮中选择名称作为其参数值。我的 Perl 代码如下:
if ( param("q1") eq undef ) {
$an1 = 0;
$winner = 0;
print <<"BIG";
<h1>You didn't enter the right answer</h1>
BIG
}
else {
print <<"BIG";
<h1>You entered the right answer</h1>
BIG
}
此时,如果我选中任何一个单选框,它就会说我输入了正确的答案。
有没有什么方法可以指定它从收音机中提取的值,例如 a 或 b 或 c 或 d 作为参数,还是我完全做错了?
【问题讨论】: