Reputation: 41219
I have created a website with javascript dropdown option menu.
This is my menu.php file
<select onchange="if (this.value) window.location.href=this.value">
<option value="/home.php">Home</option>
<option value="/aboutme.php">About Me</option>
<option value="/work.php">Work</option>
<option value="/contect.php">Contect Me</option>
</select>
I have included this file on every pages of website. It works fine.
Now what I want is : When I click on the aboutMe from dropdown menu in "home" It should redirect me to About Me page and dropdown menu in aboutme page should remain at about me. So far it is redirecting successfully, but dropdown menu always remains on "Home".
Is there a way to solve this ? or Should I create a saparate file for each pages?
I am confused. Please Help.
Upvotes: 1
Views: 108
Reputation: 9583
Give your select an id:
<select id="page" onchange="if (this.value) window.location.href=this.value">
and use the script:
<script>
window.onload = function(){
document.getElementById('page').value = window.location.href;
}
</script>
Upvotes: 3