Reputation: 1302
URL using "http://localhost:8000/test.html"
I want to change URL to "http://localhost:8000/test.html?countrycode=SG" or "http://localhost:8000/test.html?countrycode=MY" or "http://localhost:8000/test.html?countrycode=IN" based on the selectize value selected.
Also, On select change it have get value and refresh the page.
Thanks
HTML:
<div class="select-container">
<select class="custom-select">
<option value="SG">Singapore</option>
<option value="MY">Malaysia</option>
<option value="IN">India</option>
</select>
</div>
JS:
$('.custom-select').selectize();
Upvotes: 0
Views: 1380
Reputation: 1302
solution found for this question:
var urlpath = window.location.origin + window.location.pathname; window.location = urlpath+'?countrycode=' + value;
Thanks
Upvotes: 1
Reputation: 762
You can do this
<div class="select-container">
<select class="custom-select">
<option value="SG">Singapore</option>
<option value="MY">Malaysia</option>
<option value="IN">India</option>
</select>
</div>
$(function() {
$('.custom-select').selectize({
onChange: function(value) {
window.location = $getURLPath+'?countrycode=' + value;
}
});
});
Demo : http://jsfiddle.net/jalayoza/uZmcD/88/
Hope this helps
Upvotes: 0