DaniWeb IT Discussion Community

DaniWeb IT Discussion Community (http://www.daniweb.com/forums/)
-   JavaScript / DHTML / AJAX (http://www.daniweb.com/forums/forum117.html)
-   -   Drop down list Selected Value - Current Page (http://www.daniweb.com/forums/thread115498.html)

raywood5 Mar 24th, 2008 4:36 pm
Drop down list Selected Value - Current Page
 
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...?

hunkychop Mar 24th, 2008 7:54 pm
Re: Drop down list Selected Value - Current Page
 
here is the script:

<select id="jump">

  <option value="http://localhost/page2.html" onclick="javascript:window.location = this.value;">page2</option>
  <option value="http://localhost/page1.html" onclick="javascript:window.location = this.value;">page1</option>
  <option value="http://localhost/page3.html" onclick="javascript:window.location = this.value;">page3</option>
 
</select>
<script type="text/javascript">
var slect=document.getElementById('jump');
if(slect.value!==location.href){
        slect.value = location.href;
}
</script>


All times are GMT -4. The time now is 3:52 pm.

Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC