Drop down list Selected Value - Current Page

Please support our JavaScript / DHTML / AJAX advertiser: PostgreSQL or MySQL? Compare and contrast the two most popular open source databases
Reply

Join Date: Jan 2005
Posts: 10
Reputation: raywood5 is an unknown quantity at this point 
Solved Threads: 1
raywood5 raywood5 is offline Offline
Newbie Poster

Drop down list Selected Value - Current Page

 
0
  #1
Mar 24th, 2008
I want to us a simple HTML drop down lists (<select name="menu"....) as a quick jump between a couple of different html pages. I was able to come up with the script to have the pages jump to the URLs. However, I was hoping to have the current page dynmically selected. For example, If I am on the page for Nike Running Shoes (nike-running-shoes.html) that value in the drop down would be selected.

Any suggestions...?
Reply With Quote Quick reply to this message  
Join Date: Mar 2007
Posts: 55
Reputation: hunkychop is an unknown quantity at this point 
Solved Threads: 4
hunkychop's Avatar
hunkychop hunkychop is offline Offline
Junior Poster in Training

Re: Drop down list Selected Value - Current Page

 
0
  #2
Mar 24th, 2008
here is the script:

  1. <select id="jump">
  2.  
  3. <option value="http://localhost/page2.html" onclick="javascript:window.location = this.value;">page2</option>
  4. <option value="http://localhost/page1.html" onclick="javascript:window.location = this.value;">page1</option>
  5. <option value="http://localhost/page3.html" onclick="javascript:window.location = this.value;">page3</option>
  6.  
  7. </select>
  8. <script type="text/javascript">
  9. var slect=document.getElementById('jump');
  10. if(slect.value!==location.href){
  11. slect.value = location.href;
  12. }
  13. </script>
toast
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



Tag cloud for JavaScript / DHTML / AJAX
About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC