问题描述:

I am using jdev 11.1.2.2 to build a quiz web application. So i want to set up a count down timer on a jsf page which shows the remaining time before the quizzer runs out of time. how can i achieve this?

Thanks.

网友答案:

You can have a simple javascript for it:

<form name="TIMER"><input type="text" size="8" 
name="d2"></form> 

<script> 
<!-- 
// 
 var milisec=0 
 var seconds=30 
 document.counter.d2.value='30' 

function display(){ 
 if (milisec<=0){ 
    milisec=9 
    seconds-=1 
 } 
 if (seconds<=-1){ 
    milisec=0 
    seconds+=1 
 } 
 else 
    milisec-=1 
    document.counter.d2.value=seconds+"."+milisec 
    setTimeout("display()",100) 
} 
display() 
--> 
</script> 

Or you can try something like this.

相关阅读:
Top