ボタン時計 PART1

ボタン上に時刻を表示する。ありそうでなかったかも。

実行結果


ヘッダ部分
<SCRIPT LANGUAGE="JavaScript">
function nowTime()	{
	today = new Date()
	var t = (today.getHours() >= 10) ? today.getHours() : "0" + today.getHours()
	var m = (today.getMinutes() >= 10) ? today.getMinutes() : "0" + today.getMinutes()
	var s = (today.getSeconds() >= 10) ? today.getSeconds() : "0" + today.getSeconds()
	document.clock.now_time.value = t + ":" + m + ":" + s
	timerID = setTimeout("nowTime()" , 1000);
}
</SCRIPT>

ボディ部分 <BODY onLoad="nowTime()"> : : <FORM NAME="clock"> <INPUT TYPE="button" NAME="now_time" value="時刻を表示します"> </FORM>