我正在尝试编写一项调查,一次只显示一个问题,每个问题都在单独的页面上。我无法弄清楚如何让我的 CGI 文件完成此操作,现在我将所有内容都放在一个页面上,但希望我的用户能够点击“下一步”按钮将他们带到一个新问题。我正在尝试专门使用 Perl 和 HTML 来做到这一点。例如:
use CGI qw(:standard); # Include standard HTML and CGI functions
use CGI::Carp qw(fatalsToBrowser); # Send error messages to browser
#
# Start by printing the content-type, the title of the web page and a heading.
#
print header, start_html("Hello"), h1("Hello");
if (param()) { # If true, the form has already been filled out.
$who = param("myname");
$cats = param("cats"); # Extract the value passed from the form.
if($cats == "Y"){
print p("Hello, your name is $who, and you like cats");
}
else{
print p("Hello, your name is $who, and you don't like cats"); # Print the name.
}
}
else { # Else, first time through so present form.
print start_form();
print p("What's your name? ", textfield("myname"));
print p("Do you like cats? Y for yes and N for no", textfield("cats"));
print p(submit("Submit form"), reset("Clear form"));
print end_form();
}
print end_html;
如果我希望猫问题出现在下一页上,通过取出提交按钮并放入一个功能类似于下一个的按钮,我是否必须将按钮链接到另一个页面或者可以在一个脚本中实现?简而言之,您可以创建并链接多个 html 页面以仅使用一个 cgi 脚本进行调查吗?