admin管理员组文章数量:1336643
I have a small issue regarding the use of a <select></select>
I receive data from a server with an request. For this request I used shtml.
Now what I want is that when an user selects an item in de selectbox the page gets the data of that item from the server. An request to the server can look like this %! tcp-connections
So what I think i have to do is an page refresh with JavaScript or something like that. Can someone tell me how I can do this?
I have a small issue regarding the use of a <select></select>
I receive data from a server with an request. For this request I used shtml.
Now what I want is that when an user selects an item in de selectbox the page gets the data of that item from the server. An request to the server can look like this %! tcp-connections
So what I think i have to do is an page refresh with JavaScript or something like that. Can someone tell me how I can do this?
Share Improve this question edited Sep 18, 2014 at 7:50 ashokhein 1,05813 silver badges38 bronze badges asked Sep 18, 2014 at 7:10 user3996249user39962493 Answers
Reset to default 4HTML:
<select id="select">
<option selected>Default</option>
<option value="refresh">Refresh</option>
</select>
JavaScript:
function onchange(e) {
if (e.currentTarget.value === 'refresh') {
window.location.reload();
}
}
document.getElementById('select').addEventListener('change', onchange);
Demo: http://jsfiddle/w425208t/
Use window.location.href = yourUrl;
It will "redirect" you to page with url yourUrl
you can use any of these :
window.location.reload(false);
// If we needed to pull the document from
// the web-server again (such as where the document contents
// change dynamically) we would pass the argument as 'true'.
//i.e. 'true' will force the page to reload from the server. 'false' will reload from cache, if available.
or
location.reload();
or
window.location.replace(window.location.pathname);
本文标签: javascriptreload page when item selected in ltselectgtHTMLStack Overflow
版权声明:本文标题:javascript - reload page when item selected in <select> - HTML - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1742342411a2456867.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论