我提示用户选择日期并单击输入,但我很难显示用户选择的内容。换句话说,日期菜单返回默认值。这是代码:
选择开始日期
<select name="startmonth">
<option value="1"> January </option>
<option value="2"> February </option>
<option value="3"> March </option>
<option value="4"> April </option>
<option value="5"> May </option>
<option value="6"> June </option>
<option value="7"> July </option>
<option value="8"> August </option>
<option value="9"> September </option>
<option value="10"> October </option>
<option value="11"> November </option>
<option value="12"> December </option>
</select>
<select name="startyear">
<option value="2010"> 2010 </option>
<option value="2011"> 2011 </option>
<option value="2012"> 2012 </option>
<option value="2013"> 2013 </option>
<option value="2014"> 2014 </option>
</select>
<input type = "submit" name="EnteredDate" value = "Enter">
答案 0 :(得分:0)
由于您使用的是CGI,请观察以下cgi脚本。它会输出您演示过的两个选择框,但会在提交时自动填充其值。
#!/usr/bin/perl
use CGI;
use warnings;
use strict;
my $q = CGI->new;
print $q->header();
print qq{<html><body><form method="post">};
print $q->popup_menu(
-name => 'startmonth',
-values => [1..12],
-labels => {qw(1 January 2 February 3 March 4 April 5 May 6 June 7 July 8 August 9 September 10 October 11 November 12 December)},
);
print $q->popup_menu(
-name => 'startyear',
-values => [2010..2014],
);
print qq{<input type="submit" value="submit" /></form></body></html>};
1;
__END__