1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

Countdown timer.. should be easy!

Discussion in 'JavaScript' started by love_bug, Jul 31, 2008.

  1. #1
    Hi im not good with javascripts.. so can someone show me how to show countdown timer (10 to 0) on a submit button, i mean when click on it.. not on pageload..thanks
    SEMrush
     
    love_bug, Jul 31, 2008 IP
    SEMrush
  2. yleiko

    yleiko Peon

    Messages:
    74
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    0
    #2
    
    <script language="javascript">
    function countdown(i)
    {
    	i--;
    	if(i > 0) {
    		document.getElementById("myButton").value = "last "+i+"seconds"
    		setTimeout("countdown("+i+")", 1000);
    	} else {
    		document.getElementById("myButton").value = "Do it again"
    	}
    }
    </script>
    <input type="button" id="myButton" value="Click Me" onclick="countdown(10)" />
    
    
    Code (markup):
     
    yleiko, Aug 1, 2008 IP