Change dropdown value to match page change

<select id="location-search"  onChange="window.location.href=this.options[this.selectedIndex].value;"> > 
    <option value="http://dignitytech.com/efront/contact-us/">Ireland</option>

    <option value="http://dignitytech.com/efront/united-kingdom-2/">United Kingdom</option>

    <option value="http://dignitytech.com/efront/spain/">Spain</option>

    <option value="http://dignitytech.com/efront/romania/">Romania</option> 

</select>

      

Now I want to change the dropdown according to the page change.

Somebody help me

+3


source to share


2 answers


You can achieve this with this simple line of code executed on page load:



$('#location-search').val(location.href);

      

+2


source


Based on what you already have, I am assuming that you have exactly this choice across multiple pages. If so, then just on each page check the appropriate value (so when you are on contact-us

, check this option with the attribute selected

).



0


source







All Articles