OT Drop Down Scripts

Discussion in 'HTML' started by Davmagic .Com, Oct 14, 2004.

  1. I am currently using JavaScript to run my Drop Downs, and would like to
    change to a CGI Script, maybe Perl...

    Where can I find a simple and secure Perl script to do this?

    Web Design, Magic, Painting, Junking, More
    http://www.davmagic.com
    Paint A House
    http://www.paintahouse.com
    NOTE: This emailbox is CLOSED do NOT reply!!!
     
    Davmagic .Com, Oct 14, 2004
    #1
    1. Advertising

  2. "Davmagic .Com" <> wrote in message
    news:...
    >I am currently using JavaScript to run my Drop Downs, and would like to
    > change to a CGI Script, maybe Perl...
    >
    > Where can I find a simple and secure Perl script to do this?



    cgi-resources.com used to have a bunch of good ones. I haven't been there
    lately though.

    --Tina
    --
    http://www.AffordableHOST.com - Managed, Dedicated and Colo Servers
    http://www.AxisHost.com - High bandwidth Cpanel Hosting Accounts
    Datacenter located in Grand Rapids, Michigan
    Serving the web since 1997
     
    Tina - AffordableHOST, Inc., Oct 14, 2004
    #2
    1. Advertising

  3. Davmagic .Com

    Hywel Guest

    In article <>, Davmagic
    ..Com says...
    > I am currently using JavaScript to run my Drop Downs, and would like to
    > change to a CGI Script, maybe Perl...
    >
    > Where can I find a simple and secure Perl script to do this?


    http://cgi.resourceindex.com/ - if you can't find a ready-written script
    to do it you'll certainly find a CGI library that will take care of
    getting at the form data.

    --
    Hywel

    http://sponsorhywel.org.uk/
     
    Hywel, Oct 14, 2004
    #3
  4. I looked at cgi resources and couldn't find what I want... no script to
    process drop downs... any other suggestions? And since I don't write
    script...

    Web Design, Magic, Painting, Junking, More
    http://www.davmagic.com
    Paint A House
    http://www.paintahouse.com
    NOTE: This emailbox is CLOSED do NOT reply!!!
     
    Davmagic .Com, Oct 14, 2004
    #4
  5. Davmagic .Com

    aa Guest

    What are Drop Dawns?
     
    aa, Oct 14, 2004
    #5
  6. Davmagic .Com

    Steve Pugh Guest

    On Thu, 14 Oct 2004 20:27:34 +0100, "aa" <> wrote:

    >What are Drop Dawns?


    Well you know the phrase "dawn has broken"? What do you think comes
    before the break?

    Steve
     
    Steve Pugh, Oct 14, 2004
    #6
  7. Davmagic .Com wrote:

    > I looked at cgi resources and couldn't find what I want... no script to
    > process drop downs...


    I find that hard to believe ... but I hacked this together in a couple of
    minutes. I suggest you learn Perl, it isn't difficult:

    (Changes should be obvious. Name your select element "link".)

    #!/usr/bin/perl

    use strict;
    use warnings;
    use CGI;

    my $site_root = 'http://www.example.com/thing/';

    my %pages = (
    home => '',
    away => 'away/',
    far_far_away => 'away/run.html'
    );

    my $location = $site_root . '/'; # Default

    my $cgi = new CGI;

    $location = $site_root . $pages{$cgi->param('link')}
    if (
    defined $cgi->param('link') &&
    defined $pages{$cgi->param('link')}
    );

    print <<EOF;
    Location: $location
    Content-Type: text/html; charset=iso-8859-1

    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
    "http://www.w3.org/TR/html4/strict.dtd">
    <title>Document Found!</title>
    <h1>Document Found!</h1>
    <p>The document you were looking for can be found at
    <a href="$location">$location</a>.</p>
    EOF

    --
    David Dorward <http://blog.dorward.me.uk/> <http://dorward.me.uk/>
    Home is where the ~/.bashrc is
     
    David Dorward, Oct 14, 2004
    #7
  8. Davmagic .Com

    Hywel Guest

    In article <>, Davmagic
    ..Com says...
    > I looked at cgi resources and couldn't find what I want... no script to
    > process drop downs... any other suggestions? And since I don't write
    > script...


    Learn to write script. It's easier with PHP, so perhaps starting at
    http://www.php.net/ would be good.

    --
    Hywel

    http://sponsorhywel.org.uk/
     
    Hywel, Oct 14, 2004
    #8
  9. Davmagic .Com

    aa Guest


    > Well you know the phrase "dawn has broken"?


    I don't. English ain't my mother tonge
    What are Drop Dawns in this context?
     
    aa, Oct 14, 2004
    #9
  10. aa wrote:

    > I don't. English ain't my mother tonge
    > What are Drop Dawns in this context?


    In this context ... you are still misspelling them. See the subject for the
    correct spelling.

    A "Drop Down" is, I suspect, referring to a <select> element since they are
    commonly rendered as what, in most GUI toolkits, are referred to as Drop
    Down Menus.


    --
    David Dorward <http://blog.dorward.me.uk/> <http://dorward.me.uk/>
    Home is where the ~/.bashrc is
     
    David Dorward, Oct 14, 2004
    #10
  11. On Thu, 14 Oct 2004 12:54:24 -0400, Davmagic .Com wrote:

    > I am currently using JavaScript to run my Drop Downs, and would like to
    > change to a CGI Script, maybe Perl...


    What do you mean, "run your drop downs"?

    --
    Jeffrey D. Silverman |
    Website | http://www.newtnotes.com

    Drop "PANTS" to reply by email
     
    Jeffrey Silverman, Oct 15, 2004
    #11
  12. Davmagic .Com

    aa Guest

    The OP seems to loose interest, but to me too the question as is makes no
    sense
     
    aa, Oct 15, 2004
    #12

  13. >From:
    >(Jeffrey Silverman)
    >On Thu, 14 Oct 2004 12:54:24 -0400,
    >Davmagic .Com wrote:
    >>I am currently using JavaScript to run my
    >>Drop Downs, and would like to change to
    >>a CGI Script, maybe Perl...

    >What do you mean, "run your drop
    >downs"?


    JavaScript processes the drop down select element.... causing the
    browser to goto the chosen option value.... source my front page to see
    the code for the drop down on it... as an example

    I want to use a Perl CGI Script to eliminate the 11% (or so) who have JS
    disabled on their browsers...

    ...but can't seem to find a readily available script, that will work
    just like the JS that I use now... ie goes to the page when the select
    option is clicked, without having a "Go" button to press... and goes
    _directly_ to the page, without having the script return a page with a
    link on it, to be clicked to goto the desired page (as David Dorward's
    script proposal suggests)...

    Web Design, Magic, Painting, Junking, More
    http://www.davmagic.com
    Paint A House
    http://www.paintahouse.com
    NOTE: This emailbox is CLOSED do NOT reply!!!
     
    Davmagic .Com, Oct 16, 2004
    #13
  14. Davmagic .Com

    Toby Inkster Guest

    Davmagic .Com wrote:

    > I want to use a Perl CGI Script to eliminate the 11% (or so) who have JS
    > disabled on their browsers...


    If I were you, I'd use a combination Javascript and PHP solution. This
    will use Javascript for those who can, and fall back to PHP for the rest:

    In your <head>:

    <script type="text/javascript">
    function redirect() {
    var sel = document.getElementById("r");
    var sid = sel.selectedIndex;
    var page = sel.options[sid].value;
    window.location.href = page;
    return false;
    }
    </script>

    In your <body>:

    <form action="/redirect.php" method="GET" onsubmit="redirect();">
    <div>
    <select id="r" name="r">
    <option value="/index.html">Home</option>
    <option value="/contact.html">Contact Me</option>
    <option value="/blah.html">Blah</option>
    </select>
    </div>
    </form>

    And here is redirect.php, which should be put into your document root:

    <?php
    $page = $_GET['r']
    header('HTTP/1.1 302 Found');
    header("Location: $page");
    ?>
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
    "http://www.w3.org/TR/html4/strict.dtd">
    <title>HTTP/1.1 302 Found</title>
    <h1>HTTP/1.1 302 Found</h1>
    <p>The document you were looking for can be found at
    <a href="<?= $page ?>"><?= $page ?></a>.</p>

    and that's it. More efficient that a straight server-side redirect.

    --
    Toby A Inkster BSc (Hons) ARCS
    Contact Me ~ http://tobyinkster.co.uk/contact
    Now Playing ~ ./beatles/blue_cd1/02_penny_lane.ogg
     
    Toby Inkster, Oct 16, 2004
    #14
  15. Davmagic .Com

    Toby Inkster Guest

    Toby Inkster wrote:

    > <form action="/redirect.php" method="GET" onsubmit="redirect();">
    > <div>
    > <select id="r" name="r">
    > <option value="/index.html">Home</option>
    > <option value="/contact.html">Contact Me</option>
    > <option value="/blah.html">Blah</option>
    > </select>
    > </div>
    > </form>


    Argh! You're going to want a submit button in there somewhere too!

    --
    Toby A Inkster BSc (Hons) ARCS
    Contact Me ~ http://tobyinkster.co.uk/contact
    Now Playing ~ ./travis/love_will_come_through.ogg
     
    Toby Inkster, Oct 16, 2004
    #15

  16. >From:
    >(Toby Inkster)
    >If I were you, I'd use a combination
    >Javascript and PHP solution. This will use
    >Javascript for those who can, and fall
    >back to PHP for the rest:
    ><snip code>


    Thanks, but it doesn't seem to work... I copied all your code,
    implimented it as you indicated, but get an ERROR "File not found" when
    hitting the submit button!

    Again I don't need a submit button with the current JS script that I now
    use... and would like to "keep it that way" with any other scripts that
    I convert to...

    But your code doesn't seem to work as you explained anyway, I had JS
    enabled, but it used the form action and used the php script anyway...
    did not use the JS? Still did get the ERROR...

    Web Design, Magic, Painting, Junking, More
    http://www.davmagic.com
    Paint A House
    http://www.paintahouse.com
    NOTE: This emailbox is CLOSED do NOT reply!!!
     
    Davmagic .Com, Oct 16, 2004
    #16
  17. Davmagic .Com

    Toby Inkster Guest

    Davmagic .Com wrote:

    > Thanks, but it doesn't seem to work... I copied all your code,
    > implimented it as you indicated, but get an ERROR "File not found" when
    > hitting the submit button!


    Let's have a look. URL?

    > Again I don't need a submit button with the current JS script that I now
    > use... and would like to "keep it that way" with any other scripts that
    > I convert to...


    Well, you can't. Tough. Without a submit button, how can people submit the
    form?

    --
    Toby A Inkster BSc (Hons) ARCS
    Contact Me ~ http://tobyinkster.co.uk/contact
     
    Toby Inkster, Oct 16, 2004
    #17

  18. >From:
    >(Toby Inkster)
    >Let's have a look. URL?


    http://davmagic.com/testindex.html

    >Well, you can't. Tough. Without a submit
    >button, how can people submit the form?


    The JS that I am using now, uses the "onchange" event for the select tag
    to submit the form, here's the URL: http://davmagic.com/index.html

    Why can't this be done with another non-JS script?

    Web Design, Magic, Painting, Junking, More
    http://www.davmagic.com
    Paint A House
    http://www.paintahouse.com
    NOTE: This emailbox is CLOSED do NOT reply!!!
     
    Davmagic .Com, Oct 16, 2004
    #18
  19. Davmagic .Com wrote:

    > The JS that I am using now, uses the "onchange" event for the select tag
    > to submit the form, here's the URL: http://davmagic.com/index.html


    > Why can't this be done with another non-JS script?


    There are two ways to submit forms. With client side scripting (which isn't
    reliable) and with submit buttons (which have to be activated by the user).

    --
    David Dorward <http://blog.dorward.me.uk/> <http://dorward.me.uk/>
    Home is where the ~/.bashrc is
     
    David Dorward, Oct 16, 2004
    #19
  20. Davmagic .Com

    Steve Pugh Guest

    On Sat, 16 Oct 2004 11:50:25 -0400, (Davmagic .Com)
    wrote:
    >>From: (Toby Inkster)
    >>If I were you, I'd use a combination
    >>Javascript and PHP solution. This will use
    >>Javascript for those who can, and fall
    >>back to PHP for the rest:
    >><snip code>

    >
    >Thanks, but it doesn't seem to work... I copied all your code,
    >implimented it as you indicated, but get an ERROR "File not found" when
    >hitting the submit button!


    First thing to check: does your server support PHP?

    >Again I don't need a submit button with the current JS script that I now
    >use... and would like to "keep it that way" with any other scripts that
    >I convert to...


    Not possible. The form must be submitted to the serve in order for a
    server side script to handle it. This requires either JavaScript
    (pointless if the server side script is a fallback for when JS is
    disabled) or a submit button.

    Steve
     
    Steve Pugh, Oct 16, 2004
    #20
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. SirPoonga
    Replies:
    2
    Views:
    807
    Ben Strackany
    Jan 7, 2005
  2. weiwei
    Replies:
    0
    Views:
    1,053
    weiwei
    Jan 5, 2007
  3. msimmons
    Replies:
    0
    Views:
    528
    msimmons
    Jul 16, 2009
  4. Replies:
    5
    Views:
    305
  5. Replies:
    3
    Views:
    315
Loading...

Share This Page