1N/A#!/usr/local/bin/perl
1N/A
1N/Ause CGI;
1N/A$query = new CGI;
1N/Aprint $query->header;
1N/A$TITLE="Frameset Example";
1N/A
1N/A# We use the path information to distinguish between calls
1N/A# to the script to:
1N/A# (1) create the frameset
1N/A# (2) create the query form
1N/A# (3) create the query response
1N/A
1N/A$path_info = $query->path_info;
1N/A
1N/A# If no path information is provided, then we create
1N/A# a side-by-side frame set
1N/Aif (!$path_info) {
1N/A &print_frameset;
1N/A exit 0;
1N/A}
1N/A
1N/A# If we get here, then we either create the query form
1N/A# or we create the response.
1N/A&print_html_header;
1N/A&print_query if $path_info=~/query/;
1N/A&print_response if $path_info=~/response/;
1N/A&print_end;
1N/A
1N/A
1N/A# Create the frameset
1N/Asub print_frameset {
1N/A $script_name = $query->script_name;
1N/A print <<EOF;
1N/A<html><head><title>$TITLE</title></head>
1N/A<frameset cols="50,50">
1N/A<frame src="$script_name/query" name="query">
1N/A<frame src="$script_name/response" name="response">
1N/A</frameset>
1N/AEOF
1N/A ;
1N/A exit 0;
1N/A}
1N/A
1N/Asub print_html_header {
1N/A print $query->start_html($TITLE);
1N/A}
1N/A
1N/Asub print_end {
1N/A print qq{<P><hr><A HREF="../index.html" TARGET="_top">More Examples</A>};
1N/A print $query->end_html;
1N/A}
1N/A
1N/Asub print_query {
1N/A $script_name = $query->script_name;
1N/A print "<H1>Frameset Query</H1>\n";
1N/A print $query->start_form(-action=>"$script_name/response",-TARGET=>"response");
1N/A print "What's your name? ",$query->textfield('name');
1N/A print "<P>What's the combination?<P>",
1N/A $query->checkbox_group(-name=>'words',
1N/A -values=>['eenie','meenie','minie','moe']);
1N/A
1N/A print "<P>What's your favorite color? ",
1N/A $query->popup_menu(-name=>'color',
1N/A -values=>['red','green','blue','chartreuse']),
1N/A "<P>";
1N/A print $query->submit;
1N/A print $query->endform;
1N/A}
1N/A
1N/Asub print_response {
1N/A print "<H1>Frameset Result</H1>\n";
1N/A unless ($query->param) {
1N/A print "<b>No query submitted yet.</b>";
1N/A return;
1N/A }
1N/A print "Your name is <EM>",$query->param(name),"</EM>\n";
1N/A print "<P>The keywords are: <EM>",join(", ",$query->param(words)),"</EM>\n";
1N/A print "<P>Your favorite color is <EM>",$query->param(color),"</EM>\n";
1N/A}
1N/A