html - Dropdown option menu with javascript -


i have created website javascript dropdown option menu.

this 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 file on every pages of website. works fine.

now want : when click on aboutme dropdown menu in "home" should redirect me about me page , dropdown menu in aboutme page should remain @ about me. far redirecting successfully, dropdown menu remains on "home".

is there way solve ? or should create saparate file each pages?

i confused. please help.

give select id:

<select id="page" onchange="if (this.value) window.location.href=this.value"> 

and use script:

<script>   window.onload = function(){     document.getelementbyid('page').value =  window.location.href;   } </script> 

Comments