<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=windows-1251">
<title>Часы</title>
</head>
<body>
<div align="center">
<p> <span id="clock1" style="width:450px; font-size:10px"></span> </p>
</div>
<script type="text/javascript">
<!--
var hour0=0;
var min0=0;
var sec0=0;
var timeId=null;
function form2 (v) { return (v<10?'0'+v:v); }
function changetime() {
sec0--;
if (sec0<0) {
sec0=59;
min0--;
if (min0<0) {
min0=59;
if (hour0>0) hour0--;
else { hour0=min0=sec0=0; }
}
}
}
function showtime () {
var t=hour0*3600+min0*60+sec0;
if (t>0) {
document.getElementById('clock1').innerHTML = form2(hour0)+':'+form2(min0)+':'+form2(sec0);
changetime();
}
else if (t<1) {
document.getElementById('clock1').innerHTML = '';
window.clearTimeout (timeId);
timeId=null;
}
}
function inittime (hour,min,sec) {
if (timeId) {
window.clearTimeout (timeId);
timeId=null;
}
hour0=Math.max(hour,0); min0=Math.max(min,0); sec0=Math.max(sec,0);
if (!timeId) {
timeId=window.setInterval("showtime();",1000);
}
}
// -->
</script>
<script type="text/javascript">
function generate_list (name,min,step,max,deft) {
document.writeln ('<select name="'+name+'" size="1">');
for (var i=min; i<=max; i+=step) {
document.write ('<option value="'+i+'"');
if (i==deft) { document.write (' selected'); }
document.writeln ('>'+(i<10?'0'+i:i)+'</option>');
}
document.writeln ('</select>');
}
</script>
<div align="center">
<form name="f1">
<table align="center" width="90%" border="0" cellpadding="4" cellspacing="0"><tr>
<td>Часы: <script type="text/javascript">generate_list ('hour0',0,1,50,1);</script></td>
<td>Минуты: <script type="text/javascript">generate_list ('min0',0,1,59,0);</script></td>
<td>Секунды: <script type="text/javascript">generate_list ('sec0',0,1,59,0);</script></td>
<td><input type="button" value="Отсчёт"
onclick="inittime(
document.f1.hour0.options[document.f1.hour0.selectedIndex].value,
document.f1.min0.options[document.f1.min0.selectedIndex].value,
document.f1.sec0.options[document.f1.sec0.selectedIndex].value);"></td>
</tr></table>
</form>
</div>
</body>
</html> |