본문 바로가기

Programming/javascript

[javasciprt] 시간 카운트

시간 카운트



js

<script type="text/javascript">

function flowtime(){

chantime_m = setTimeout("timebar_m()", 1000);

}

  

function timebar_m(){

var ti = document.all.timebox_m.value;

ti = ti - 1;

  

if(ti < 1){

document.all.result_m.value = "end count";

}else{

var sec = ti % 60;

var min = (ti - sec) / 60;

window.document.all.sec_m.value = sec;

window.document.all.min_m.value = min;

window.document.all.timebox_m.value = ti;

chantime = setTimeout("timebar_m()", 1000);

}  

}

  

function cleartime(){

clearTimeout(chantime_m);

}

  

flowtime();

</script>


jsp

<body>

<input type ="text" name = "timebox_m" value = "120" size = "10"><br>

<input type ="text" name = "min_m" value = "120" size = "3"><br>

<input type ="text" name = "sec_m" value = "120" size = "3"> <br>

<input type ="text" name "result_m">

</body>