[英]Selectize - on change add URL parameter and refresh the page
使用“ http:// localhost:8000 / test.html ”的URL
我想将URL更改为“ http:// localhost:8000 / test.html?countrycode = SG ”或“ http:// localhost:8000 / test.html?countrycode = MY ”或“ http:// localhost:8000” /test.html?countrycode=IN “基于所选的选择值。
此外,在选择更改时,它会获得价值并刷新页面。
谢谢
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();
你可以这样做
<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;
}
});
});
演示: http : //jsfiddle.net/jalayoza/uZmcD/88/
希望这可以帮助
找到此问题的解决方案:
var urlpath = window.location.origin + window.location.pathname; window.location = urlpath +'?countrycode ='+值;
谢谢
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.