Commit | Line | Data |
---|---|---|
920dae64 AT |
1 | #!/usr/local/bin/perl |
2 | ||
3 | use CGI; | |
4 | $query = new CGI; | |
5 | print $query->header; | |
6 | $TITLE="Frameset Example"; | |
7 | ||
8 | # We use the path information to distinguish between calls | |
9 | # to the script to: | |
10 | # (1) create the frameset | |
11 | # (2) create the query form | |
12 | # (3) create the query response | |
13 | ||
14 | $path_info = $query->path_info; | |
15 | ||
16 | # If no path information is provided, then we create | |
17 | # a side-by-side frame set | |
18 | if (!$path_info) { | |
19 | &print_frameset; | |
20 | exit 0; | |
21 | } | |
22 | ||
23 | # If we get here, then we either create the query form | |
24 | # or we create the response. | |
25 | &print_html_header; | |
26 | &print_query if $path_info=~/query/; | |
27 | &print_response if $path_info=~/response/; | |
28 | &print_end; | |
29 | ||
30 | ||
31 | # Create the frameset | |
32 | sub print_frameset { | |
33 | $script_name = $query->script_name; | |
34 | print <<EOF; | |
35 | <html><head><title>$TITLE</title></head> | |
36 | <frameset cols="50,50"> | |
37 | <frame src="$script_name/query" name="query"> | |
38 | <frame src="$script_name/response" name="response"> | |
39 | </frameset> | |
40 | EOF | |
41 | ; | |
42 | exit 0; | |
43 | } | |
44 | ||
45 | sub print_html_header { | |
46 | print $query->start_html($TITLE); | |
47 | } | |
48 | ||
49 | sub print_end { | |
50 | print qq{<P><hr><A HREF="../index.html" TARGET="_top">More Examples</A>}; | |
51 | print $query->end_html; | |
52 | } | |
53 | ||
54 | sub print_query { | |
55 | $script_name = $query->script_name; | |
56 | print "<H1>Frameset Query</H1>\n"; | |
57 | print $query->startform(-action=>"$script_name/response",-TARGET=>"response"); | |
58 | print "What's your name? ",$query->textfield('name'); | |
59 | print "<P>What's the combination?<P>", | |
60 | $query->checkbox_group(-name=>'words', | |
61 | -values=>['eenie','meenie','minie','moe']); | |
62 | ||
63 | print "<P>What's your favorite color? ", | |
64 | $query->popup_menu(-name=>'color', | |
65 | -values=>['red','green','blue','chartreuse']), | |
66 | "<P>"; | |
67 | print $query->submit; | |
68 | print $query->endform; | |
69 | } | |
70 | ||
71 | sub print_response { | |
72 | print "<H1>Frameset Result</H1>\n"; | |
73 | unless ($query->param) { | |
74 | print "<b>No query submitted yet.</b>"; | |
75 | return; | |
76 | } | |
77 | print "Your name is <EM>",$query->param(name),"</EM>\n"; | |
78 | print "<P>The keywords are: <EM>",join(", ",$query->param(words)),"</EM>\n"; | |
79 | print "<P>Your favorite color is <EM>",$query->param(color),"</EM>\n"; | |
80 | } | |
81 |