Click to See Complete Forum and Search --> : Creating a drop down menu with hyperlinks


AttilaTheHun
12-23-2003, 07:12 PM
Can someone help me with the code "How to hyperlink selections inside a drop down menu to open a new page" I am sure there are various ways to accomplish this so either or both of the following would work for me.

1. When a selection is clicked in a drop down menu. "it is hyperlinked to open a new page"

OR

2. User clicks on a selection from the drop down menu and then has to click a button to visit the hyperlinked page for that selection.


Please help, Thanks

Paul Jr
12-23-2003, 07:18 PM
See if this (http://forums.webdeveloper.com/showthread.php?s=&threadid=23925) helps at all.

pyro
12-23-2003, 07:29 PM
You would probably be best to combine this with a server-side script, to keep it working for those without JavaScript enabled. Something like this:

<form action="<?PHP echo $_SERVER['PHP_SELF']; ?>" method="post">
<p><select name="url" onchange="document.location.href=this.options[this.selectedIndex].value">
<option value="">Choose a site</option>
<option value="http://www.ryanbrill.com/">http://www.ryanbrill.com</option>
<option value="http://www.infinitypages.com/">http://www.infinitypages.com</option>
</select>
<input type="submit" name="submit" value="go"></p>
</form>
With this at the very top of the page:
<?PHP
if (isset($_POST['submit'])) {
header("Location:".$_POST['url']);
}
?>

Khalid Ali
12-23-2003, 07:40 PM
and ofcourse if you do nothave access to a webserver with php enabled,here is a simple JavaScript solution... (http://www.webapplikations.com/pages/html_js/forms/DropDownOpenSelectedLink.html)

pyro
12-23-2003, 07:45 PM
Or, you could just not use the PHP part, as the one that I posted also uses JavaScript. ;)

Paul Jr
12-23-2003, 07:47 PM
Originally posted by pyro
Or, you could just not use the PHP part, as the one that I posted also uses JavaScript. ;)
Heheh, I swear, this place could function just fine with only Pyro here to answer questions ;).

AttilaTheHun
12-23-2003, 08:30 PM
I wish to thank Paul Jr, Pyro & Khalid Ali for your fast reply to help me. I've been trying to hunt down this solution for nearly a year now exhausting myself over it at times. I cant explain in words the jubilation I am feeling now.

Paul Jr. - I was able to find a script from the link you provided that works with my browser... THANK YOU!!!

Pyro - I am not sure if my server supports your script method, I havnt been able to try it out yet. How do I find out if my host provider supports this server side PHP application your talking about? I like the fact that your code covers a majority of older version browsers and I would rather implement this type of method into my site.

Khalid Ali - I was not able to locate the code for the script on that link unless I viewed the source of the page from my own browser. Since your version is only supported in 5.0 browsers and higher, I probably wont be interested in using it. But I wish to thank you for the investment of your precious time to try and help me.

Khalid Ali
12-23-2003, 08:35 PM
you are welcome...btw the code is tested against IE6+ and NS6+ means exactly what it says,usually it would mean that it will forl for most of the IE browsers.....;)

Paul Jr
12-23-2003, 08:40 PM
Originally posted by AttilaTheHun
Paul Jr. - I was able to find a script from the link you provided that works with my browser... THANK YOU!!!
You're welcome. I try to do the itty-bitty amount I can to ensure my existance here is not just sucking up everyone's knowledge ;). Whether I am succeeding or not is debatable.

pyro
12-23-2003, 09:10 PM
Upload the page to a server, with a .php extention, and try it with JavaScript disabled. If it works, your server supports PHP.

Alternatly, upload this (again, with a .php extention) and run it to check if your server supports PHP.

<?PHP
echo "I have PHP!";
?>

AttilaTheHun
12-23-2003, 09:23 PM
Pyro...

I HAVE PHP... HURRAYYY!! THANK YOU THANK YOU!

Later when I have time I will try out your method and see if I can work with it.

I just became a subscriber to this forum today and I wish I would have known or found it much sooner. All of you have been true to form. This place is awesome and so are you guys.

PeOfEo
12-23-2003, 09:28 PM
Kind of makes ya feel all warm and fuzzy inside doesnt it? :D

pyro
12-23-2003, 09:44 PM
Good deal. Hope it works for you (it should).

A little late, but welcome to the forums! Glad you found them helpful. :)

Khalid Ali
12-23-2003, 10:14 PM
Originally posted by AttilaTheHun
Pyro...

I HAVE PHP..
I think it will be safe to say that most of the webservers today do have php(because most of them are apache,I seriously doubt if there are any missin critical apps running on IIS).
I guess as it proved in this case its just allots of people just don't know if they can utilise server side scripting and be safer in browser compliance.

AttilaTheHun
12-23-2003, 10:48 PM
Well Pyro,

I am not an advanced web developer. Just simple HTML skeleton style works best for me. When you talk about PHP and SQL and other stuff like that... it is not very familiar territory to me so I may need time and patience to understand.

Yes it is too late that I found this place... funny, it has been right under my nose for many months thru one of those news letters I subscribed to. I don't have time to read all my email subscriptions and visit every link offered to me. Today I am glad I took the time out to discover.

PeOfEo,
Fuzzy and warm doesnt even come close to describing how happy I am to be able to create a drop down menu with hyperlinks. I bet there are also other variations that will accomplish this task available out there.

PeOfEo
12-24-2003, 02:02 AM
Originally posted by AttilaTheHun
PeOfEo,
Fuzzy and warm doesnt even come close to describing how happy I am to be able to create a drop down menu with hyperlinks. I bet there are also other variations that will accomplish this task available out there. Well me saying warm and fuzzy was direct at pyro for getting thank you for helping someone :p