• perlcgiform2


    代码:

     

            #!/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

    完! 

  • 相关阅读:
    Ubuntu12.04 下安装QQ
    python下sqlite增删查改方法(转)
    你有哪些想要分享的 PyCharm 使用技巧?
    PEP 8
    macos 下安装virtualenv,virtualenvwrapper,然后在pycharm中正常配置方法日志
    最全Python爬虫总结(转载)
    Git 常用命令详解
    Python 扩展技术总结(转)
    使用setup.py安装python包和卸载python包的方法
    IPython3 notebook 成功配置Python2和Python3内核(Kernel)
  • 原文地址:https://www.cnblogs.com/itech/p/2748044.html
Copyright © 2020-2023  润新知