javascript - Change input select based on url? -


i have website dropdown select menu

<select class="tmcp-field tm-epo-field tmcp-select"   		name="tmcp_select_0"   		data-price=""   		data-rules=""   		id="tmcp_select_1"   		tabindex="1"  >  	<option  selected='selected' value="basislayout_0" data-price="0" data-rules="[&quot;0&quot;]" data-rulestype="[&quot;&quot;]">basislayout</option><option  value="profilayout_1" data-price="24" data-rules="[&quot;24&quot;]" data-rulestype="[&quot;&quot;]">profilayout</option>	</select>	

how can have option "profilayout" preselected on page load, when line append url ?start_customizing=yes

you can achieve this. condition location.search.indexof('start_customizing=yes') != -1 raw, feel free modify if needed.

if(location.search.indexof('start_customizing=yes') != -1) {     document.getelementbyid('tmcp_select_1').value="profilayout_1"; } 

https://jsfiddle.net/t7k545dm/1/


Comments

Popular posts from this blog

cakephp - simple blog with croogo -

How to group boxplot outliers in gnuplot -

bash - Performing variable substitution in a string -