I want to have a cgi-script that does two things.
Take the input from a form.
Generate results base on the input values on a frame.
Primarily I want the frame exist only after the results is generated/printed.
Below is the simplified code of what I want to do. But somehow it doesn't work.
What's the right way to do it?
#!/usr/local/bin/perl
use CGI ':standard';
print header;
print start_html('A Simple Example'),
h1('A Simple Example'),
start_form,
"What's your name? ",textfield('name'),
p,
"What's the combination?",
p,
checkbox_group(-name=>'words',
-values=>['eenie','meenie','minie','moe'],
-defaults=>['eenie','minie']),
p,
"What's your favorite color? ",
popup_menu(-name=>'color',
-values=>['red','green','blue','chartreuse']),
p,
submit,
end_form,
hr;
if (param()) {
# begin create the frame
print <<EOF;
<html><head><title>$TITLE</title></head>
<frameset rows="10,90">
<frame src="$script_name/query" name="query">
<frame src="$script_name/response" name="response">
</frameset>
EOF
# Finish creating frame
print
"Your name is: ",em(param('name')),
p,
"The keywords are: ",em(join(", ",param('words'))),
p,
"Your favorite color is: ",em(param('color')),
hr;
}
print end_html;