Jump to content

Timer Countdown


mcmuney

Recommended Posts

Is there a way to modify this script to work outside of a form? Working Link

 

<form name="counter"><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> 

Link to comment
Share on other sites

i thnk this shoud work:

var time = document.getElementById("yourElement");
time.innerHtml = 30;
//then later
time.innerHtml = seconds+"."+milisec 

 

you can use this is a variety of elements linke div, span, ect.

just put the elements id where it says yourElement

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.