Jump to content
php.lv forumi

Pulkstenis kas skaita uz prieksu


djmartins

Recommended Posts

Atradu skriptu kur pulkstenis skaita uz prieksu bet vins skaita milisekundes un sekundes.Tacu man vajag lai butu minutes un stundas un viss.Kaa taa var uztaisit?Kur kas butu japamaina?

<script>

<!--

 

 

 

var milisec = 0;

var seconds = 0;

 

function display(){

if (milisec>=9){

milisec=0

seconds+=1

}

else

milisec+=1

document.d.d2.value = seconds + "." + milisec;

setTimeout("display()",100);

}

 

-->

</script>

<body onload="display();">

 

<form name="d">

<input type="text" size="8" name="d2">

</form>

Link to comment
Share on other sites

Nu sita izdariju bet tagad vispar nestrada kas pa vainu?

 

 

<!--

 

 

 

var minute = 0;

var hours = 0;

 

function display(){

if (minute>=9){

minute=0

hours+=1

}

else

minute+=1

document.d.d2.value = hours + "." + minute;

setTimeout("display()",100);

}

 

-->

</script>

<body onload="display();">

 

<form name="d">

<input type="text" size="8" name="d2">

</form>

Link to comment
Share on other sites

Pilnais variants, kas man iet:

 

<html>
<head>
<script>
<!--
var minute = 0;
var hours = 0;

function display(){
minute += 1;
if (minute >= 60){
	minute = 0
	hours += 1
}

document.d.d2.value = hours + ":" + (minute < 10 ? '0' : '') + minute;
setTimeout("display()", 1000);
}

//-->
</script>
<body onload="display();">

<form name="d">
<input type="text" size="8" name="d2">
</form>
</body>
</html>

 

Pārliecinies, ka vēlāk netiek mainīts window.onload vai document.body.onload (neesmu pārliecināts).

Link to comment
Share on other sites

×
×
  • Create New...