Im using java script in JSP the problem is i need auto refresh on selectin checkbox it's working fine but on unselecting it's not stopping the auto refresh activity .plz suggest Thanks in advance
function autorefresh() {
var isChecked = document.getElementById("is_check").checked;
var time = 0;
if (isChecked == true) {
time = setInterval(function () {
showExport()
}, 5000);
} else if (isChecked == false) {
clearInterval(time);
}
}
timeoutside of the function. Also note that you can reduceif (x == true) {...} else if (x == false) {...}toif (x) {...} else {...}.setInterval(function () { showExport() }, 5000);-->setInterval(showExport, 5000);autorefreshis called multiple times? (although he never said it in his question or I missed it probably)