Click to See Complete Forum and Search --> : Drop Down Menu -- when selection made automatically taken to page w/ out pressing GO
GreyFaerie
10-08-2003, 05:30 PM
Ive seen this many times, and i need this for my site. In a drop down menu, when you select an option, I want it to automatically take you to the page without pressing 'Go'. I have viewed sources with pages that have this feature and I have a feeling it has to do with an 'onchange' I am seeing in the select tags. if so... i have no idea how to use it. can someone please help me?
You could use something like this:
<form action="">
<p><select onchange="window.location.href=this.options[this.selectedIndex].value">
<option value="http://www.w3c.org">W3C</option>
<option value="http://www.webdevfaqs.com">Web Dev FAQs</option>
</select></p>
</form>Though you should combine it with a PHP or Perl script to keep it working for those without JavaScript enabled...
GreyFaerie
10-08-2003, 06:39 PM
is there anything in the onchange that i need to edit?
Nope... But like I said, does your server support either PHP or Perl to use as a backup, or do you have an alternate, accessible way to access those pages?
GreyFaerie
10-08-2003, 10:03 PM
I have no clue... my server supports php i know that. i use plesk 6.0 if that helps
Ok, then, here's what you want:
<?PHP
if (isset($_POST['submit'])) {
header("Location:".$_POST['loc']);
}
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<title>The Accessible Way...</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<body>
<form action="<?PHP echo $_SERVER['PHP_SELF']; ?>" method="post">
<p><select name="loc" onchange="window.location.href=this.options[this.selectedIndex].value">
<option value="http://www.w3c.org">W3C</option>
<option value="http://www.webdevfaqs.com">Web Dev FAQs</option>
</select>
<input type="submit" name="submit" value="Go"></p>
</form>
</body>
</html>
GreyFaerie
10-10-2003, 06:28 AM
thanks. i havent put that on there yet but now i have another problem. my whole website loads in an iframe (you can go check it out at www.playingwithfaeries.com) .. now the page that i am using this feature on is at www.playingwithfaeries.com/PetColours.htm . if you goto the page the script works perfectly... but when you goto it from the link on my site (its under guides in the link called 'Pet Colours) it doesnt work... at least not for me. Is that becuase i dont have the php on there yet , or maybe does it have to do that becuase it loaded in another iframe? or is there something else... thanks!
You'll want to use self.location.href instead of window.location.href...
GreyFaerie
10-10-2003, 05:23 PM
can you tell me exactly what i need to edit on the php?
this is what i am seeing :
'submit' - ??
"Location:" - "iframe name":
'loc' - ???
'PHP_SELF" - php file name
With a PHP header redirect, you won't be able to direct the individual frame...