-5
    print button(
      -name =>'GOOD',
      -value    =>'GOOD',
      -onclick=>'redirect_GMM()'
    );

    sub redirect_GMM()
      {
         print redirect(-url=>'http://localhost/cgi-bin/GMW/GMM.pl');
      } 

perlでonclickを使ってボタンクリックでページをリダイレクトしたい。

      print "User name:\t";

        print $q->textfield(
              -name => 'UserName',
               -value =>'Google',
               -size  => 15,
               -maxlength =>25,
            ); 
             my $uName = $q->param('UserName');
             print "<script>alert($uName)</script>";

テキストフィールドの値を取得していません。

4

1 に答える 1

0
      Using the javascript in Perl we can redirect the page from perl file to the another perl file

       Step 1  use CGI qw(:standard);

       Step 2   my $JSCRIPT=<<EOF;

                function redirect_GMM()
                {
                window.location.href = 'http://localhost/cgi-bin/GMW/GMM.pl';
                }   
                EOF
                 ;  
       Step 3  my $q =CGI->new;
               print $q->header('text/html');
               print $q->start_html(-title=>'JJ',-script=>$JSCRIPT);
               print $q->h5('JJ login page');
               print $q->end_html; 

       Step 4   print button(
                         -name =>'GOOD',
                         -value    =>'GOOD',
                         -onclick=>'redirect_GMM()'
                          );

         This code will surely redirect the page when you press the button.
于 2013-09-06T11:30:05.537 に答える