1
I Have This Code:
<html>
<form method="POST">
<textarea name="txt" value="" rows="5" cols="100"></textarea>
<br></br>
<input type="button" name="" value="Message" onClick="btfunc()" style="width:100; height:100" wrap="soft">
</form>
<script charset="utf-8">
var strs = ["C++", "Python"];
var i = 0;
var strpos = 0;
function btfunc()
{
while (i < strs[strpos].length)
{
if (strpos > strs.length - 1)
{
break;
}
else
{
if (i == strs[strpos].length - 1)
{
document.forms[0].elements[0].value += strs[strpos].charAt(i);
i = -1;
strpos++;
document.forms[0].elements[0].value += "\n";
i++;
setTimeout(btfunc, 2000);
}
else
{
document.forms[0].elements[0].value += strs[strpos].charAt(i);
i++;
setTimeout(btfunc, 100);
}
}
}
}
</script>
</html>
When I Click the Button It Inserts All Text Without Pausing In SetTimeouts, Pq It Happens ?
This code is a bit confusing. Can you explain what you want to do? (apart from the problem with timeouts...)
– Sergio
He’ll write down whatever’s on array and from one element to the other he jumps a line in the textarea, only with an effect of (Typing) example:C (0.1Sec After) + (0.1Sec After) + Got it ?
– axell-brendow
After finishing an element it skips a wait line two seconds and starts writing the other element of array, the code works the way I want the problem is that it does not pause.
– axell-brendow