PDA

View Full Version : CountDown Timer Issue



Byronwells
03-02-2009, 06:10 AM
Alright guys

I need some really big help please.. :)

I would like to be able to have a count down timer (whether it be days,hours, mins, etc) on my salepages to force the buyer to buy there any then

I would like the time to display as on this on http:// www.bclstore.net/Re/dmc.html

I am wondering if I can get the timer also to do the following please:

1) when the timer reaches zero it goes automatically goes to another salespage with a higher price on it.


2) Lets say that I launch a product for 2 hours before the special price runs and the visitors looks at the salepage 1h58m - to display exactly how long is left (not that they have still got 2h left)

3) Also to link number of products.. Lets say I have got 100 products to sell for a $1 but you can only get them within the next two hours.. So it all depends which ones goes first


I do already have a php script that does most of the above, but does not display the timer nothing like the above..

Can anyone help me either change the php code or find something in javascript please?

techker
03-02-2009, 02:02 PM
i have isaluated thecode for the timer.se iuf you can figure it out from here.



<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>Top Secret Magic Code</title>


</head>
<body topmargin="0" style="background:#F7F7FF URL(/images_template/bg-page-new.jpg) repeat-x left top;" >
<!--- START HEADER --->
<div style="width:774px; height:29px; margin:0 auto; padding:0 0 20px 0;">
<!--- START NAV AREA --->
<!--- END NAV AREA --->
<div style="margin-top:30px; margin-bottom:0; padding-bottom:0;"></div>


<!--- END HEADER --->

<!--- START CONTENT AREA --->
<div id="ContentContainer">



<!--- COUNTDOWN START --->
<div style="clear:both;">
<table align="center" border="0" cellpadding="0" cellspacing="0"><tr>
<!--<td> <img src="images_letter/watch.jpg" width="155" height="128"> </td>-->
<td style="padding-right:20px;">

<script type="text/javascript">
var countdownstart;
var epochtimemilliseconds = GetCookie();
var nowdate = new Date();
var nowtime = nowdate.getTime();
var redirect_url = "http://www.topsecretmagiccode.com/indxtmsup.php";
var daystoexp = "3";

if (epochtimemilliseconds > 0)
{
milliseconds_elapsed = nowtime - epochtimemilliseconds;
if (milliseconds_elapsed >= (86400000 * daystoexp)) //86400 seconds in 1 day, times 1000 milliseconds/second
{
location.replace(redirect_url);
}
else { countdownstart = Math.round(((86400000 * daystoexp) - milliseconds_elapsed)); } //boda-change
}
else
{
countdownstart = 86400 *1000 * daystoexp;//boda-change
WriteCookie("etmindx", nowtime);
}

function WriteCookie(name,value)
{
var exp = '';
var cookieExpiration = 365; // days
var today = nowdate;
var expdate = nowtime + (cookieExpiration * 24 * 60 * 60 * 1000);
today.setTime(expdate);
exp = '; expires=' + today.toGMTString();
document.cookie = name + "=" + value + '; path=/;domain=www.topsecretmagiccode.com' + exp;
}

function GetCookie()
{
var cookiecontent;
if(document.cookie.length > 0)
{
var cookiename = 'etmindx=';
var cookiebegin = document.cookie.indexOf(cookiename);
var cookieend = 0;
if(cookiebegin > -1)
{
cookiebegin += 8;
cookieend = document.cookie.indexOf(";",cookiebegin);
if(cookieend < cookiebegin)
{
cookieend = document.cookie.length;
}
cookiecontent = document.cookie.substring(cookiebegin,cookieend);
}
else { cookiecontent = 0; }
}
else { cookiecontent = 0; }
return cookiecontent;
}


var _countDowncontainer=0;
var _currentMilliseconds=0; //boda-change

function ActivateCountDown(strContainerID, strContainerID2, initialValue)
{
_countDowncontainer = document.getElementById(strContainerID);
_countDowncontainer2 = document.getElementById(strContainerID2);

if (!_countDowncontainer) {
alert("count down error: container does not exist: "+strContainerID+"\nmake sure html element with this ID exists");
return;
}
if (!_countDowncontainer2) {
alert("count down error: container does not exist: "+strContainerID2+"\nmake sure html element with this ID exists");
return;
}
SetCountdownText(initialValue);
window.setTimeout("CountDownTick()", 100); //boda-change
}

function CountDownTick()
{
if (_currentMilliseconds <= 0) { //boda-change
location.replace(redirect_url); //alert("your time has expired!");
return;
}

SetCountdownText(_currentMilliseconds); //boda-change
window.setTimeout("CountDownTick()", 100); //boda-change
}

function SetCountdownText(milliseconds) {
//store:
if (milliseconds < 1) { location.replace(redirect_url); }

// Calculate the interval since the last update and adjust currentMilliseconds.
var currentDate = new Date();
var currentTime = currentDate.getTime();
var elapsed = currentTime - nowtime;
_currentMilliseconds = milliseconds - elapsed;

// Don't double-count the elapsed time; update the 'nowtime' to the current time
nowtime = currentTime;

// New calculation code
var days = Math.floor(milliseconds / (24 * 60 * 60 * 1000));
milliseconds -= days * (24 * 60 * 60 * 1000);
var hours = Math.floor(milliseconds / (60 * 60 * 1000));
milliseconds -= hours * (60 * 60 * 1000);
var minutes = Math.floor(milliseconds / (60 * 1000));
milliseconds -= minutes * (60 * 1000);
var seconds = Math.floor(milliseconds / 1000);
milliseconds -= seconds * 1000;
var tenths = Math.floor(milliseconds / 100);

//build text:
var strText = "<span style='color:#000'>Hurry! Price goes up in: <br></span> " + AddZero(days) + " <span style='color:#c00000'>days</span> | " + AddZero(hours) + " <span style='color:#c00000'>hours</span> | " + AddZero(minutes) + " <span style='color:#c00000'>minutes</span> | " + AddZero(seconds) + "." + tenths + " <span style='color:#c00000'>seconds</span>"; //Dave-change
var strText2 = "<span style='color:#000'>Reminder! Price goes up in: <br></span> " + AddZero(days) + " <span style='color:#c00000'>days</span> | " + AddZero(hours) + " <span style='color:#c00000'>hours</span> | " + AddZero(minutes) + " <span style='color:#c00000'>minutes</span> | " + AddZero(seconds) + "." + tenths + " <span style='color:#c00000'>seconds</span>"; //Dave-change


//apply:
_countDowncontainer.innerHTML = strText;
_countDowncontainer2.innerHTML = strText2;
}

function AddZero(num) {
return ((num >= 0)&&(num < 10))?"0"+num:num+"";
}


function WindowLoad(event) { ActivateCountDown("CountDownPanel","CountDownPanel2",countdownstart); }
</script>
<center>
<span style='font-size:10pt;font-family:"Arial","sans-serif"; font-weight:bold; color:#c00000;'>
<span id="CountDownPanel"></span>
</span>
</center>
</td>
</tr></table>
</div>
<!--- COUNTDOWN END --->

<br><br>
<P CLASS="Heading1"><br>
<!--- COUNTDOWN START --->
</P>
<div style="clear:both;">
<table align="center" border="0" cellpadding="0" cellspacing="0"><tr>
<td>&nbsp;</td>
<td style="padding-right:20px;">
<center>
<span style='font-size:10pt;font-family:"Arial","sans-serif"; font-weight:bold; color:#c00000;'>
<span id="CountDownPanel2"></span>
</span>
</center>
<script type="text/javascript">
<!--
WindowLoad();
//-->
</script>
</td>
</tr>
</table>
</div>
<!--- COUNTDOWN END --->
<P ><br>
</P>
</div>

</body>
</html>