I am trying to fix the code ….let me explain and paste the code here:
I have a textarea, and textbox. When i start typing something in the textarea, the time in the textbox incerases by 1 sec and stops at 5 second if user stop typing…again when user start typing it goes next 5 seconds…..as long as the user types the time goes on…..
What i need to do: ex: I have a textbox (which has 100 as value let us say) when the user types in the textarea count in the textbox goes for 101,102,103,104,105….if the user stops, if NOT it goes along)…I have a code it works if the user starts fresh, But NOT it takes from a textbox already has some value in it (let us say 100 in the above case)
Here is the code which works for a fresh start with empty textbox, my need is to increase the time if something has already in it (ex 100), and the user types some thing in the textarea the time increases by 5 secs…say 101,102,…..
[CODE]
<script type=”text/javascript”>
var seconds = 0,
timer = null,
timestop = null;
function increaseSeconds() {
++seconds;
document.getElementById(“timer”).value = seconds;
}
function startTimer() {
timer = setInterval(increaseSeconds, 1000);
}
function stopTimer() {
clearInterval(timer);
timer = null;
}
function descriptionKeyUp() {
if (timer === null) {
startTimer();
}
else {
clearTimeout(timestop);
}
timestop = setTimeout(stopTimer, 6000);
}
</script>
PHP/HTML CODE:
html:
<form>
<tr>
<th scope=”row”><textarea name=”taskdesc” cols=”45″ rows=”10″ id=”taskdesc” onkey onkeyup=”descriptionKeyUp()”></textarea></th>
</tr>
<p>typing time:
<input type=”input” name=”seconds” id=”timer” value=”0″ />
<input type=”submit” id=”submit” value=”Submit” />
</p>
</form>