prova questo esempio
codice:
<!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" lang="it" xml:lang="it">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<script type="text/javascript">
// <![CDATA[
function writeTime() {
f_ore = document.getElementById('ore');
f_min = document.getElementById('minuti');
dt = new Date();
f_ore.value = (dt.getHours() < 10)? "0" + dt.getHours() : dt.getHours();
f_min.value = (dt.getMinutes() < 10)? "0" + dt.getMinutes() : dt.getMinutes();
}
function changeTime(f, val) {
f_val = parseInt(document.getElementById(f).value, 10);
f_val += val;
if ((f_val < 0) && (f == 'ore')) f_val = 23;
if ((f_val > 23) && (f == 'ore')) f_val = 0;
if ((f_val < 0) && (f == 'minuti')) f_val = 59;
if ((f_val > 59) && (f == 'minuti')) f_val = 0;
document.getElementById(f).value = (f_val < 10)? "0" + f_val : f_val;
}
window.onload = writeTime;
// ]]>
</script>
<style type="text/css">
div {
float : left;
width : 60px;
}
input {
height : auto;
width : 54px;
font-size : 40px;
}
button {
width : 10px;
text-align : center;
}
</style>
</head>
<body>
<div>
<input type="text" readonly="readonly" id="ore" />
<button onclick="changeTime('ore' , -1);"><</button><button onclick="changeTime('ore' , 1);">></button>
</div>
<div>
<input type="text" readonly="readonly" id="minuti" />
<button onclick="changeTime('minuti' , -1);"><</button><button onclick="changeTime('minuti' , 1);">></button>
</div>
</body>
</html>
Ciauz
Edit: vedo adesso la provenienza: stasera vado al bowling di quarto d'altino...