How do I get the code window.location.href
right with value
of <option
:
<script type="text/javascript">
jQuery(document).ready(function($){
$('select').find('option[value=window.location.href]').attr('selected','selected');
});
</script>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.0.0/jquery.min.js"></script><select><optionvalue="http://www.test.com/page0">Japanese yen (JPY)</option>
<option value="http://www.test.com/page1">Afghan afghani (AFN)</option>
<option value="http://www.test.com/page2">Albanian lek (ALL)</option>
<option value="http://www.test.com/page3">Algerian dinar (DZD)</option>
<option value="http://www.test.com/page4">Angolan kwanza (AOA)</option>
<option value="http://www.test.com/page5">Argentine peso (ARS)</option>
<option value="http://www.test.com/page6">Armenian dram (AMD)</option>
<option value="http://www.test.com/page7">Aruban florin (AWG)</option>
<option value="http://www.test.com/page8">United States dollar (USD)</option>
</select>
Example url browser: link will be selected
<select>
<option value="http://www.test.com/page8" selected="selected" >United States dollar (USD)</option>
<option value="http://www.test.com/page0">Japanese yen (JPY)</option>
<option value="http://www.test.com/page1">Afghan afghani (AFN)</option>
<option value="http://www.test.com/page2">Albanian lek (ALL)</option>
<option value="http://www.test.com/page3">Algerian dinar (DZD)</option>
<option value="http://www.test.com/page4">Angolan kwanza (AOA)</option>
<option value="http://www.test.com/page5">Argentine peso (ARS)</option>
<option value="http://www.test.com/page6">Armenian dram (AMD)</option>
<option value="http://www.test.com/page7">Aruban florin (AWG)</option>
</select>