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);
发布者:admin,转转请注明出处:http://www.yc00.com/questions/1742342412a4425891.html
评论列表(0条)