|
Q917 How can I count down from 15 seconds and then display an alert message?
irt.org | Knowledge Base | JavaScript | Date | Q917 [ previous next ]
Q917 How can I count down from 15 seconds and then display an alert message?
Try:
<form name="timer">
<input type="text" value="" name="field">
</form>
<script language="JavaScript"><!--
var counter = 15;
function countDown() {
document.timer.field.value = counter-- + ' seconds left';
if (counter != -1)
setTimeout('countDown()',1000);
else
alert('You lose');
}
countDown();
//--></script>
|
|
|
Copyright © 1996-2008 irt.org, All Rights Reserved.