Client Side Things
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Codewalkers ForumsOther TechnologiesClient Side Things

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Codewalkers Forums Sponsor:
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  
Old October 18th, 2004, 12:08 PM
spank spank is offline
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Apr 2007
Location: Maryland, USA
Posts: 48 spank User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 2
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.

php Code:
Original - php Code
  1.  
  2. echo "<select>";
  3.         
  4.          for($i=1;$i <= $numOfPages;$i++)
  5.              {
  6.                     if($i == $page)
  7.                         {
  8.                              echo "<option>".$i;
  9.                             }
  10.                     else
  11.                         {
  12.                              echo "<option><a href="$PHP_SELF?page=$i" class="paging">$i</a>";
  13.                             }
  14.                  }//-- end for
  15. echo "</select>";      

Reply With Quote
  #2  
Old October 18th, 2004, 01:14 PM
niko_zeta niko_zeta is offline
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Apr 2007
Location: Rossmoyne, WA, Australia
Posts: 105 niko_zeta User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 2
Send a message via ICQ to niko_zeta Send a message via AIM to niko_zeta Send a message via Yahoo to niko_zeta
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.

Reply With Quote
  #3  
Old October 18th, 2004, 01:38 PM
spank spank is offline
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Apr 2007
Location: Maryland, USA
Posts: 48 spank User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 2
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.


Reply With Quote
  #4  
Old October 18th, 2004, 11:49 PM
niko_zeta niko_zeta is offline
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Apr 2007
Location: Rossmoyne, WA, Australia
Posts: 105 niko_zeta User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 2
Send a message via ICQ to niko_zeta Send a message via AIM to niko_zeta Send a message via Yahoo to niko_zeta
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 :-)


Reply With Quote
  #5  
Old October 19th, 2004, 10:48 AM
spank spank is offline
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Apr 2007
Location: Maryland, USA
Posts: 48 spank User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 2
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.

Reply With Quote
  #6  
Old October 22nd, 2004, 04:08 PM
rehfeld_dot_us rehfeld_dot_us is offline
Codewalkers Novice (500 - 999 posts)
 
Join Date: Apr 2007
Posts: 825 rehfeld_dot_us User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 2
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...

Reply With Quote
  #7  
Old October 22nd, 2004, 05:10 PM
spank spank is offline
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Apr 2007
Location: Maryland, USA
Posts: 48 spank User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 2
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.

Reply With Quote
Reply

Viewing: Codewalkers ForumsOther TechnologiesClient Side Things > Links in drop down menu


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 1 hosted by Hostway