i want to create a timer for my php page i created the page that only 20 second i want that the time should be as 00:00:20 (hh:mm:ss) plz help my scipt are..........................................................................................................

<tr>
        <!-- countdown script --> 
            <td style="text-align:left;font-size:10pt;font-family:Verdana, Arial;">Time Left: <input type="text" name="seconds" size="3">
            <script language="javascript" type="text/javascript">
                var myTime = 20;
                function countDown() {
                    document.form.seconds.value = myTime;
                    if (myTime == 0) {
                        location.href="trivia1.php";
                    }
                    else if (myTime > 0) { 
                        myTime--;
                        setTimeout("countDown()",1000);
                    }
                }
                
                countDown();
            </script>
            </td>
</tr>

are you looking for something like this :

document.form.seconds.value = "00:00:" + (myTime < 10 ? "0" + myTime : myTime);

@gazzy1
1. Start using code tags as [code] YOUR CODE HERE [/code]
2. Make sure you post in proper section, not posting PHP stuff in JSP(Java Server Section) or JS(Java Script) in PHP section

or all accumulated infractions will get your account banned...

document.form <- form points to name="form" which was missing

<script language="javascript" type="text/javascript">
var myTime = "20";
function countDown() {
	document.form.seconds.value = myTime;
	if (myTime == 0)
	{
		location.href="trivia1.php";
	}
	else if (myTime > 0)
	{
		myTime--;
		setTimeout("countDown()",1000);
	}
}
</script>

<body onload="countDown();">
<form name="form">
Time Left: <input type="text" name="seconds" size="3">
</form>
</body>

The script above passed the second to 0 (starting from 20 second. I need 1500 seconds but the time show as 00:25:59, 00:25:58................00:25:01...00:24:00...00:24:59........................untill 00:00:00.


Plz help me

Have a look at your newer post gazzy1.

Check this out:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en-us">

<head>

<title>Timer</title>

<script type="text/javascript">
var timeInput;
var timeButton;
var timeDiv;
var timerDate;
var timerHandler;

function startTimer() {
	var timeStr = timeInput.value;
	if(timeStr == null || timeStr == "") return;
	
	var timeValues = timeStr.split(":");
	var th = parseInt(timeValues[0], 10);
	var tm = parseInt(timeValues[1], 10);
	var ts = parseInt(timeValues[2], 10);
	
	timerDate = new Date();
	timerDate.setHours(th);
	timerDate.setMinutes(tm);
	timerDate.setSeconds(ts);
	
	if(timerHandler) {
		timerHandler = clearInterval(timerHandler);
	}
	
	if(th == 0 && tm == 0 && ts == 0) return;
	
	if(timeButton.value == "Start") {
		timerHandler = setInterval(update, 1000);
		timeButton.value = "Stop";
	} else {
		timeButton.value = "Start";
	}
}

function update() {
	var th = timerDate.getHours();
	var tm = timerDate.getMinutes();
	var ts = timerDate.getSeconds();
	
	var str = (th < 10 ? ( "0" + th ): th) + ":"
			+ (tm < 10 ? ( "0" + tm ): tm) + ":"
			+ (ts < 10 ? ( "0" + ts ): ts);
	timeDiv.innerHTML = str;
	
	timerDate.setSeconds(--ts);
}
</script>

</head>

<body>
<input type="text" id="time"></input>
<input type="button" id="start" value="Start" onclick="startTimer();"></input>
<div id="apDiv3"></div>
<script type="text/javascript">
timeInput = document.getElementById('time');
timeDiv = document.getElementById('apDiv3');
timeButton = document.getElementById('start');
</script>
</body></html>