|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
Stay one step ahead of the competition. Evaluate and give feedback
on some of the hottest web development tools on the market today.
Make your opinion heard! Click
Here
|
|
#1
|
|||
|
|||
|
Links in drop down menu
I'm trying to use a drop down menu to show the number of pages retrieved from a query. I have working "Previous" and "Next" links, but I can't get the links in the drop down menu to work. I know that you can do this with Javascript. Is there anyway to do it with PHP or staight HTML? I thank you in advance for your time. Code is below. I am aware the the select has no name, etc. I just wrote it out to get the idea across. Thanks again.
|
|
#2
|
|||
|
|||
|
RE: Links in drop down menu
You can't do this with PHP or just HTML. A drop-down menu cannot contain anchor tags. THe only way I know is to use a little JavaScript.
the onChange attribute for the select box is probably what you need, with the script: "window.open('this.value')" or something like that. |
|
#3
|
|||
|
|||
|
RE: Links in drop down menu
I was afraid of that. I guess I'll have to start learning JavaScript. Ah...the life of a n00b. ;-)
Thanks for the response. I appreciate your time. |
|
#4
|
|||
|
|||
|
RE: Links in drop down menu
Hi again. I thought I'd give you a little help here. JavaScript can be a bit tricky to learn because of the lack of official tutorials and clear documentation (something PHP can be proud of :-)
<select onChange="window.open(this.value)" name="link"> <option value="#" selected="selected"> Select an option </option> <option value="http://www.php.org"> PHP website </option> <option value="http://www.microsoft.com"> Microsoft website </option> <option value="http://www.ebay.com"> Ebay website </option> <option value="http://www.paypal.com"> PayPal website </option> </select> This is how it works: when you select an option, the select box launches the little Javascript that tells it to open a new window (window.open). "this" refers to the select object, and "value" refers to the selected option. Important to note: you must include the full URL, with http:// , or else it will look for the address in your relative path. Also, the value attribute in the option tags is necessary only if you want to show a text that differs from the value you want to send. You could obtain the same result with this: <option>http://www.microsoft.com</option> except that it's not very appealing in a drop-down box. I hope that helps :-) |
|
#5
|
|||
|
|||
|
RE: Links in drop down menu
I appreciate the extra information. I am familiar with <option> tags, but am VERY new to javascript. the onChange function should be a big help. Thanks again. It's people like you that make people like me feel comfortable learning new things.
|
|
#6
|
|||
|
|||
|
RE: Links in drop down menu
you could also do this, no js needed:
<form method="get" action="<?php echo $_SERVER['PHP_SELF']; ?>"> <p> <select name="page"> <option value="page1.php">Page 1</option> <option value="page2.php">Page 2</option> </select> </p> <p><input type="submit" value="Goto Page"></p> </form> then when the user hits submit, the url will goto your_script.php?page=page1.html not sure if thats what you wanted, but its an option its a controversial topic, but accessibility purists dont like select lists that auto submit once you select something. The "accessible" way is to let them hit submit, because thats the behavior they expect, so dont confuse/suprise them. But it really depends on the scope of which you use it imo. hope that helped... |
|
#7
|
|||
|
|||
|
RE: Links in drop down menu
I have run into a few people who think I shouldn't be doing this at all. I'm just trying to figure out a way to make my pagination a little more compact by having the page numbers in a drop down menu instead of spread out all over my page (which I think looks sloppy).
I appreciate all of your input. I really do. You have both been a huge help. |
![]() |
| Viewing: Codewalkers Forums > Other Technologies > Client Side Things > Links in drop down menu |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|
|
|
|