I've been working at this for quite some time now. I'm trying to create a simple timer that counts down. I've gotten the alert() to work, but unfortunately the textToChange does not change. I've reproduced a copy of my code below. Any help would be greatly appreciated! Thank you.
<script type="text/javascript">
var timeLeft = 0;
var changingTextElement;
var changingText = new Array();
var ctr = 0;
function timeMsg(thing)
{
var length = thing.inputbox.value*1000;
var t = setTimeout("alertMsg()",length);
timeLeft = length/1000;
initChangeText();
}
function alertMsg()
{
alert("Alert!");
}
function initChangeText(){
changingTextElement = document.getElementById("textToChange");
changingText[ctr] = changingTextElement.innerHTML;
ctr++;
while(timeLeft > 0){
changingText[ctr] = timeLeft;
timeLeft--;
ctr++;
}
ctr = 0;
setInterval("changingText()",1000);
}
function changingText() {
ctr++;
if(ctr >= changingText.length){
changingTextElement.innerHTML = 0;
}
else{
changingTextElement.innerHTML = changingText[ctr];
}
}
</script>