[inseperable changes from patch from perl-5.003_95 to perl-5.003_86]
[p5sagit/p5-mst-13.2.git] / eg / cgi / monty.cgi
1 #!/usr/local/bin/perl
2      
3 use CGI;
4  
5 $query = new CGI;
6
7 print $query->header;
8 print $query->start_html("Example CGI.pm Form");
9 print "<H1> Example CGI.pm Form</H1>\n";
10 &print_prompt($query);
11 &do_work($query);
12 &print_tail;
13 print $query->end_html;
14  
15 sub print_prompt {
16    my($query) = @_;
17  
18    print $query->start_multipart_form;
19    print "<EM>What's your name?</EM><BR>";
20    print $query->textfield('name');
21    print $query->checkbox('Not my real name');
22  
23    print "<P><EM>Where can you find English Sparrows?</EM><BR>";
24    print $query->checkbox_group(
25                                 -name=>'Sparrow locations',
26                                 -values=>[England,France,Spain,Asia,Hoboken],
27                                 -linebreak=>'yes',
28                                 -defaults=>[England,Asia]);
29  
30    print "<P><EM>How far can they fly?</EM><BR>",
31    $query->radio_group(
32                        -name=>'how far',
33                        -values=>['10 ft','1 mile','10 miles','real far'],
34                        -default=>'1 mile');
35    
36    print "<P><EM>What's your favorite color?</EM>  ";
37    print $query->popup_menu(-name=>'Color',
38                             -values=>['black','brown','red','yellow'],
39                             -default=>'red');
40  
41    print $query->hidden('Reference','Monty Python and the Holy Grail');
42  
43    print "<P><EM>What have you got there?</EM><BR>";
44    print $query->scrolling_list(
45                                 -name=>'possessions',
46                                 -values=>['A Coconut','A Grail','An Icon',
47                                           'A Sword','A Ticket'],
48                                 -size=>5,
49                                 -multiple=>'true');
50  
51    print "<P><EM>Any parting comments?</EM><BR>";
52    print $query->textarea(-name=>'Comments',
53                           -rows=>10,
54                           -columns=>50);
55    
56    print "<P>",$query->reset;
57    print $query->submit('Action','Shout');
58    print $query->submit('Action','Scream');
59    print $query->endform;
60    print "<HR>\n";
61         }
62  
63 sub do_work {
64     my($query) = @_;
65     my(@values,$key);
66
67     print "<H2>Here are the current settings in this form</H2>";
68
69     foreach $key ($query->param) {
70         print "<STRONG>$key</STRONG> -> ";
71         @values = $query->param($key);
72         print join(", ",@values),"<BR>\n";
73     }
74 }
75  
76 sub print_tail {
77     print <<END;
78 <HR>
79 <ADDRESS>Lincoln D. Stein</ADDRESS><BR>
80 <A HREF="/">Home Page</A>
81 END
82     ;
83 }