perl-cgi-form2

來源:互聯網
上載者:User
代碼:

 

        #!/usr/local/bin/perl
        use CGI ':standard';

        print header;
        print start_html("Example CGI.pm Form");
        print "<h1> Example CGI.pm Form</h1>\n";
        print_prompt();
        do_work();
        print_tail();
        print end_html;

        sub print_prompt {
           print start_form;
           print "<em>What's your name?</em><br>";
           print textfield('name');
           print checkbox('Not my real name');

           print "<p><em>Where can you find English Sparrows?</em><br>";
           print checkbox_group(
                                 -name=>'Sparrow locations',
                                 -values=>[England,France,Spain,Asia,Hoboken],
                                 -linebreak=>'yes',
                                 -defaults=>[England,Asia]);

           print "<p><em>How far can they fly?</em><br>",
                radio_group(
                        -name=>'how far',
                        -values=>['10 ft','1 mile','10 miles','real far'],
                        -default=>'1 mile');

           print "<p><em>What's your favorite color?</em>  ";
           print popup_menu(-name=>'Color',
                                    -values=>['black','brown','red','yellow'],
                                    -default=>'red');

           print hidden('Reference','Monty Python and the Holy Grail');

           print "<p><em>What have you got there?</em><br>";
           print scrolling_list(
                         -name=>'possessions',
                         -values=>['A Coconut','A Grail','An Icon',
                                   'A Sword','A Ticket'],
                         -size=>5,
                         -multiple=>'true');

           print "<p><em>Any parting comments?</em><br>";
           print textarea(-name=>'Comments',
                                  -rows=>10,
                                  -columns=>50);

           print "<p>",reset;
           print submit('Action','Shout');
           print submit('Action','Scream');
           print end_form;
           print "<hr>\n";
        }

        sub do_work {

           print "<h2>Here are the current settings in this form</h2>";

           for my $key (param) {
              print "<strong>$key</strong> -> ";
              my @values = param($key);
              print join(", ",@values),"<br>\n";
          }
        }

        sub print_tail {
           print <<END;
        <hr>
        <address>Lincoln D. Stein</address><br>
        <a href="/">Home Page</a>
        END
        }

 

具體的更多的form(checkbox,check_group,radio_group,popup_menu,hidden,scrolling_list,textarea.......), 在manpage search:  http://search.cpan.org/~markstos/CGI.pm-3.60/lib/CGI.pm

 

完! 

 

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.