Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical
 
PerlMonks  

Redirection from a pulldown menu

by Anonymous Monk
on Jan 20, 2000 at 20:36 UTC ( [id://2207]=perlquestion: print w/replies, xml ) Need Help??

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

I am a new programmer to Perl I am trying to create a drop down menu that lets you choose an option and depending on what you choose you are taken to the appropriate page. www.gamewar.com has one at the top if you don't know what I mean, I have used a Perl programming book and it tells to 'Get the HTML header and Ender' then it says 'require = "http://......... asking for PERL SCRIPT" What does this all mean?? What's an HTML Header and Ender PLLEEEEEEAAASSSSEEE, Help me!!!

Replies are listed 'Best First'.
RE: Redirection from a pulldown menu
by vroom (His Eminence) on Jan 20, 2000 at 22:15 UTC
    I'm not terribly familiar with PerlScript but you can do it with javascript. You can look at gamewar.com's way of doing it by doing a view source on that page and just changing the necessary URL's and titles:
    Here's a really simple HTML document that does the same thing but without any other confusing things going on.
    <HTML><BODY> <FORM> <SELECT NAME="mainmenu" CLASS="menu" METHOD="POST" onChange="window.op +en(this.options[this.selectedIndex].value,'_self')"> <OPTION VALUE="">Main Menu <OPTION VALUE="" SELECTED> <OPTION VALUE="http://www.perlmonks.org">Monastery Gates <OPTION VALUE="http://www.perlmonks.org/index.pl?node=tutorial +s">Tutorials </SELECT> </FORM> </BODY></HTML>
Re: Redirection from a pulldown menu
by Anonymous Monk on Jan 21, 2000 at 18:53 UTC
    Cheers ads, I used Gamecave's way in the end, the javascript works well,
Re: Redirection from a pulldown menu
by Anonymous Monk on Jan 24, 2000 at 03:20 UTC
    #!/usr/bin/perl use CGI 'param'; my $go = param('go'); print <<END; Location: $go END # add logging, etc in here. if you are setting cookies, # put them right after the Location line.
Re: Redirection from a pulldown menu
by dlc (Acolyte) on Jan 20, 2000 at 23:30 UTC

    simple enough to do in perl. here is some sample html:

    <form action='go.cgi' method='post'>
     <select name='go'>
      <option value='http://perlmonks.org/'>perlmonks.org
      <option value='http://slashdot.org/'>slashdot
      <option value='http://freshmeat.net/'>freshmeat
     </select>
     <input type='submit' value='stumbit'>
    </form>
    

    call your cgi script "go.cgi" and make it executable. you are in business.

    key point to remember

    • there must be a blank space after the end of the headers that you are printing
    • you need to either specify the full url to redirect to either in the script or in the html. incomplete or relative paths may work or may not, depending on the browser.

    sample perl script:

    #!/usr/bin/perl
    
    use CGI 'param';
    
    my $go = param('go');
    print <<END;
    Location: $go
    
    END
    # add logging, etc in here. if you are setting cookies,
    # put them right after the Location line.
    

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://2207]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others musing on the Monastery: (7)
As of 2024-04-23 19:03 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found