Jump to content

Drop Down Menu


IT-Guy

Recommended Posts

Hey

 

I clicked a couple of links online and I haven't been able to find any information regarding this: Does anyone know a good tutorial for this:

 

I have a drop down menu, I want users to be able to select an option from the menu > then hit 'submit' and get a php script to look at which ever option was chosen and if it was option 1, it goes to one URL, if it was option 2 it goes to a different URL and so on.

 

I know its quite simple so if anyone knew a script that would be benifical, but if anyone knew of a good tutorial that would be great to

Link to comment
Share on other sites

Well here is my script so far:

<form action="handle.php" method="post">
<select name=url>
<option value="http://php.about.com">Try</option>
<option value="http://www.identity.st">Identity</option>
</select>
<input type="submit" value="Go">
</form>

 

Here is handle.php

<?php
header( 'Location: http://about.php.com' ) ;
?>

 

Now when the form submits it does go to that URL above, but as you can see I have two options in the drop-down, how do I add another URL for the second option

Do I just need to add another    header( 'Location: http://what-ever.com' );  ?

Link to comment
Share on other sites

That is fine, but you do realize that you could, and probably should, be doing this without a form or PHP. Unless you don't have to worry about search engine bots or accessibility, it is best to use server-side scripting for only when it's needed. Not just because you can.

 

Your current menu will defeat search engine bots and will confuse people with disabilities that need to use screen reading aiding software.

Link to comment
Share on other sites

I dont follow what you are saying.

 

All Im doing really: Is making a drop down menu. In the drop down menu is a list of airports. Really all the user has to do is select the airport (There is only a list of five) the user just has to select which airport, hit 'Submit' and a Staff List from that particular airport is then displayed on our website. But continue with what you are saying, because if you know of a better way let me know :) I would like to avoid using PHP if I could, but if I absolutely have too, then its no big deal.

Link to comment
Share on other sites

Well, not saying this for you to avoid using PHP :) Just mentioning the fact you are probably looking at server-side scripting the wrong way. I can understand your confusion though if you are learning website design as you are learning PHP. I think this the the case since you called script to a snippet of HTML.

 

I suggest perhaps you do it the other way around. Learn website design before learning PHP. It isn't difficult really and in two or 3 weeks you will be here again, this time with a better baggage. I personally think server-side scripting is much more fun (and profitable) when we feel comfortable around HTML and CSS.

 

Your menu doesn't need PHP. In fact it will suffer from its use. You can do it with HTML and CSS. This way you will be separating content and presentation from scripting.

 

Now imagine, after having done of those, you decide that the links to the pages opened by that menu will be stored in a database. It's at that time you will want PHP. It's when you want to create dynamic content.

 

I really believe that to better understand these differences you should start by HTML, followed by CSS, followed by PHP :)

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.