I'm trying to make a script that allows a user to enter text into a field, and then seeing that text entered into a textarea as if one was typing.
JavaScript:
<script type="text/javascript">
//function to delay
function sleep(milliseconds) {
var start = new Date().getTime();
for (var i = 0; i < 1e7; i++) {
if ((new Date().getTime() - start) > milliseconds){
break;
}
}
}
function changeValue() {
var text = document.getElementById("f").value;
var dst = document.getElementById("t").innerHTML;
var index;
for (index = 0; index < text.length; ++index) {
dst += text.charAt(index);
sleep(10);
}
}
</script>
HTML
<textarea id="t"></textarea><br>
<input type="text" id="f">
<input type="button" onclick="changeValue();" value="Go">
However, clicking the button does nothing... What's the problem?
Update
Removing the sleep() function has made no change.