Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:

What is the easiest way to get the button below to redirect to a URL after it's pressed?

Ie. When they click the edit button, they are brought to www.edit.com.

Thanks!

print start_form(), table( Tr( td(), td(submit('edit')) ), ), end_form(), hr();

Replies are listed 'Best First'.
Re: Form redirection
by TVSET (Chaplain) on Dec 24, 2003 at 13:08 UTC
    Specify a form action, like this:

    print start_form(-action=>'some_page.pl'), table( Tr( td(), td(submit('edit')) ), ), end_form(), hr()

    Also you might be interested in a JavaScript solution. :)

      Right as usual. :)

      The difference between using JS and using a form is, one actually requires the JS interpreter to be on. At least with a form, prolly using the get method, it will work with old browsers like Lynx


      Play that funky music white boy..
Re: Form redirection
by exussum0 (Vicar) on Dec 24, 2003 at 13:06 UTC
    "perldoc CGI" is your friend. I'm assuming you are using CGI.pm at least :) Anyway, from CGI's pod (perldoc)...

           STARTING AND ENDING A FORM
    
               print $query->startform(-method=>$method,
                                       -action=>$action,
                                       -enctype=>$encoding);
                 <... various form stuff ...>
               print $query->endform;
    
                   -or-
    
               print $query->startform($method,$action,$encoding);
                 <... various form stuff ...>
               print $query->endform;
    
           startform() will return a <FORM> tag with the optional method, action
           and form encoding that you specify.  The defaults are:
    
               method: POST
               action: this script
               enctype: application/x-www-form-urlencoded
    
           endform() returns the closing </FORM> tag.
    
    You are using the non OO way, but the parameters should still be the same. Set your action to be http://www.edit.com

    Play that funky music white boy..