Using drop-down list to jump to other URLs

Method 1 - JavaScript only

This URL selector method uses JavaScript - a nice simple solution (if your browser supports it - Lynx doesn't, and some users disable JavaScript in browsers that do)!

Select URL to jump to:

The code to do this follows. Note the one devious trick. Only the first few OPTIONS are shown.

<!-- note fake form - all it does is allow SELECT to be displayed -->
<FORM>
Select URL to jump to: <SELECT NAME=URL onchange=window.location=this.options[selectedIndex].value>
<OPTION VALUE="http://www.dma.org/">DMA(R) home page</OPTION>
<OPTION VALUE="http://www.dma.org/appledaytonsig/">DMA(R) Apple SIG</OPTION>
<OPTION VALUE="http://www.dma.org/linuxsig/">DMA(R) Linux SIG</OPTION>
<OPTION VALUE="http://www.computerfest.com/">Computerfest(R)</OPTION>
</SELECT>
</FORM>

Method 2 - CGI only

This URL selector uses CGI, and the user needs to click the Go button to jump to the selected URL.

Select URL to jump to:


Method 3 - Both CGI & JavaScript

This URL selector method uses both JavaScript and CGI for those users who can't, or choose not to, use JavaScript. It combines the JavaScript from the first version with the CGI script of the second version to cover all bases. It's still fairly simple.

Select URL to jump to:

The code for this is identical to the first form with only two exceptions. A real CGI script is specified this time, and a SUBMIT button is included.

<FORM METHOD=POST ACTION=http://www.dma.org/cgi-bin/cgiwrap/~lundyd/redir-url.pl>
Select URL to jump to: <SELECT NAME=URL onchange=window.location=this.options[selectedIndex].value>
<OPTION VALUE="http://www.dma.org/">DMA(R) home page</OPTION>
<OPTION VALUE="http://www.dma.org/appledaytonsig/">DMA(R) Apple SIG</OPTION>
<OPTION VALUE="http://www.dma.org/linuxsig/">DMA(R) Linux SIG</OPTION>
<OPTION VALUE="http://www.computerfest.com/">Computerfest(R)</OPTION>
</SELECT>
<INPUT TYPE=SUBMIT VALUE="Go!">
</FORM>

The same CGI script is used by the 2nd and 3rd form and is fairly simple.

#!/usr/bin/perl -w

if ($ENV{'REQUEST_METHOD'} eq 'POST') {
        read(STDIN, $buffer, $ENV{'CONTENT_LENGTH'});
        @pairs = split(/&/, $buffer);
        foreach $pair (@pairs) {
                ($name, $value) = split(/=/, $pair);
                $value =~ tr/+/ /;
                $value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg;
                $FORM{$name} = $value;
        }
$url = $FORM{'URL'};
print "Location: $url\n\n";
}


[e-mail]

This is only a test. Now please go away. :-)