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!!!
>What are Drop Dawns?
Well you know the phrase "dawn has broken"? What do you think comes
before the break?
Steve
Learn to write script. It's easier with PHP, so perhaps starting at
http://www.php.net/ would be good.
--
Hywel
> 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
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
> 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
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)...
> 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
> <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
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...
> 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?
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?
> 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).
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
>>From: usenet...@tobyinkster.co.uk
>>(Toby Inkster)
>>Let's have a look. URL?
>
> http://davmagic.com/testindex.html
Hmm... strange error message. Never seen that one before. There are a
couple of typos in my original message, but nothing that would cause that.
I've put up an example working system here:
http://examples.tobyinkster.co.uk/magicdave/
>>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?
In what scripting language? If JS is disabled, we should assume that all
client side scripting is disabled. Which means that onchange, onclick,
onfoobar, etc will not work.
You can add an onchance event if you like, but you'll need to leave the
button for those people without JS.
A nifty trick though:
Do your button like this:
<input type="submit" id="foo">
Then use some Javascript to hide the button:
document.getElementById('foo').style.display="none";
That way, people with JS enabled will not see the button, and can use the
onchange; and people without JS will see the button and can use it.
Yes it does...
><snip>
>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.
OK I understand that now... a submit button _must_ be used with a server
side script...
My test page: http://davmagic.com/testindex.html
> You can add an onchance event if you like,
Without JavaScript, that is about what you get: a chance. <g>
--
-bts
-This space intentionally left blank.
> What the hell attachment did I use. I put the ode in the body
Since your WebTV thingy apparently doesn't show it, I'll paste in your
source so you can see what you sent. Scroll down to the HTML part.
Apologies to everyone else.
Path:
twister.nyroc.rr.com!news-rtr.nyroc.rr.com!news.maxwell.syr.edu!news.moat.net!newsfeed-3001.bay.webtv.net!newssorter-3001.bay.webtv.net!not-for-mail
From: dm...@webtv.net (Don And Sis)
Newsgroups: alt.html
Subject: Re: OT Drop Down Scripts
Date: Sat, 16 Oct 2004 23:07:32 -0400
Organization: WebTV Subscriber
Lines: 55
Message-ID: <18828-417...@storefull-3336.bay.webtv.net>
References: <13666-41...@storefull-3152.bay.webtv.net>
NNTP-Posting-Host: localhost.webtv.net
Mime-Version: 1.0 (WebTV)
Content-Type: Multipart/Mixed; Boundary=WebTV-Mail-12001-8694
Content-Transfer-Encoding: 7Bit
X-WebTV-Signature: 1
ETAuAhUAxIRh/WKExqhRiZukRgOwfQm8zawCFQC3mV7inYpi9JUcVdx47IowZ8Nuog==
Content-Disposition: Inline
X-WebTV-Stationery: Standard; BGColor=#000000; TextColor=#ffffff
Xref: news-rtr.nyroc.rr.com alt.html:1463249
--WebTV-Mail-12001-8694
Content-Type: Text/Plain; Charset=US-ASCII
Content-Transfer-Encoding: 7Bit
This script is in my cgi-bin dir. and I use it in my drop down in y sig.
Don
#!/usr/local/bin/perl
use CGI qw(param);
$url = param(url);
print "Location: $url\n\n"; exit;
--WebTV-Mail-12001-8694
Content-Description: signature
Content-Disposition: Inline
Content-Type: Text/HTML; Charset=US-ASCII
Content-Transfer-Encoding: 7Bit
<html><body bgcolor="#000000" text="#ffffff">
<center>
<form name=x
action="http://members.tripod.com/dirt129/cgi-bin/redirect.pl"
method=post><select name=url>
<option>Popcorns Help
<option
value=http://community-2.webtv.net/dmsmm/transloader5/>Transloader
<option value=http://community-2.webtv.net/dmsmm/Uploader/>Uploader
<option value=http://riverdrift.com/m1/sourcev.shtml
>Source Viewer
<option value=http://www.html46.com/ftptools.htm>Directory Mover
<option
value=http://community-2.webtv.net/dmsmm/Popcornstools1/>Popcorn's Tools
<option value=http://uk.geocities.com/murphy_dn/help/helpmenu.html
>Webtv How To
<option value=URL>Link Title
<option value=URL>Link Title
</select>
<input type=submit value=Go></form>
</center>
</html></table></tr></td></table></tr></td><center>
<embed src="http://members.tripod.com/dirt129/cgi-bin/
randomlep.pl"></embed>
<embed
src="http://members.tripod.com/dirt129/cgi-bin/random.pl"autostart="true"
></embed></html>
--WebTV-Mail-12001-8694--
That's what I keep telling you (all webtv'ers).... but nobody listens to
me "back there"...
Save your damn HTML for webpage building, which it was created for in
the first place, and always post and email in _plain text_ ...
Stated clearly on my Design News Group Page:
http://davmagic.com/PAGES68.html
In addition you (WebTv'ers) should _always_ Quote the previous replys
and Smallify them (as I am doing here) so USENET readers will not get
confused and will be more able to understand what the message is
about...
USENET readers: WebTv news reader software does NOT quote and indent or
smallify the previous messages... the posters must "manually" do this
themselves (or not do it as many are in the poor habit of not doing)...
WebTv'ers: To learn how to Quote and Smallify... see Copy and Paste on
the Menu(s) on this page: http://davmagic.com/PAGES38.html and follow
the links...
The OP's objective is to "eliminate the 11% (or so) who have JS disabled on
their browsers..."
Using both Javascript and PHP hardly serves this purpose.
Just complicates the code. Even does not save a trip to the server as the JS
function redirect() goes to the server.
OK I understand that now... a submit button _must_ be used with a server
side script...
So does it work now?