ash007 Posted July 3, 2009 Share Posted July 3, 2009 Hi Everybody, I have time count down code based on value fetching from database.It' working fine.But the problem now I have some moification.When I click on the button I want to increment the time by 20 seconds.How can I do this. Here I included code for your reference. Thanks in advance. ---- Multiple Countdown Clocks <html> <head> <title>Multiple Countdown Clocks</title> </head> <body> <div id="clock1">[clock1]</div> <div id="clock2">[clock2]</div> <input name="submit" type="submit" onClick="ddiff+20"> </body> <!--http://www.hashemian.com/tools/javascript-countdown.htm--> <script language="JavaScript"> StartCountDown("clock1","07/03/2009 12:31 AM -0400") //StartCountDown("clock2","07/27/2010 2:00 PM -0400") /* Author: Robert Hashemian (http://www.hashemian.com/) Modified by: Munsifali Rashid (http://www.munit.co.uk/) Modified by: Tilesh Khatri */ function StartCountDown(myDiv,myTargetDate) { var dthen = new Date(myTargetDate); var dnow = new Date('07/03/2009 12:30 AM -0400'); ddiff = new Date(dthen-dnow); gsecs = Math.floor(ddiff.valueOf()/1000); CountBack(myDiv,gsecs); } function Calcage(secs, num1, num2) { s = ((Math.floor(secs/num1))%num2).toString(); if (s.length < 2) { s = "0" + s; } return (s); } function CountBack(myDiv, secs) { var DisplayStr; var DisplayFormat = "%%D%% Days %%H%%:%%M%%:%%S%%"; DisplayStr = DisplayFormat.replace(/%%D%%/g, Calcage(secs,86400,100000)); DisplayStr = DisplayStr.replace(/%%H%%/g, Calcage(secs,3600,24)); DisplayStr = DisplayStr.replace(/%%M%%/g, Calcage(secs,60,60)); DisplayStr = DisplayStr.replace(/%%S%%/g, Calcage(secs,1,60)); if(secs > 0) { document.getElementById(myDiv).innerHTML = DisplayStr; setTimeout("CountBack('" + myDiv + "'," + (secs-1) + ");", 990); } else { document.getElementById(myDiv).innerHTML = "Auction Over"; } } /* function AddTime(myDiv, secs, add) { newsecs = secs + add; CountBack(myDiv, newsecs); }*/ </script> </html> Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.