This code display count down time to refresh current webpage.
The counter value is hardcoded to 10 seconds.
How can I add “input box”, that would be displayed right next to counter, to be able to change value ?
<html>
<head>
<script type="text/javascript">
var sec=10;
function time() {
if(sec==0) {
window.location.reload(true)
} else {
sec--;
document.getElementById('tm').innerHTML=(sec < 10) ? ("0" + sec) : sec;
setTimeout("time();", 1000);
}
}
</script>
</head>
<body onload="time()">
Time to refresh:
<span id="tm">10</span>
</body>
It’s important for me to ask, because we volunteer here to help people learn, but instead people expect us to complete their homework for them, or to do work for people who have no interest in learning how to code.
That’s not what we’re here for. Or at least, it’s not what I’m here for.
If you are interested in learning then well and good. If it’s for something else, then someone else might come along who will code up the exact solution that you’re looking for, so that you don’t have to do any learning.
Blame it on a bad case of the flu that I have right now.
You don’t do that with javascript. It’s a form, and it’s HTML. It has nothing to do with PHP or javascript.
The only difference between PHP and JS is, that if you want the form to send its values to a JS function, you’ll have to add some JS code somewhere in the form. Just google for ‘javascript form tutorial’ or something like that and I’m sure you’ll find lots of examples.