Jump to content

Time countdown problem


ash007

Recommended Posts

Hi everybody,

 

I have time countdown code.

I integrated this in while loop and time is incrementing......But still problem is coming..

1.after refreshing page the second div is gone and first div only displaying..

2.if i will click button 3 or more times without refershing the page the time increment not in proper order.

 

  anybody have suggestion for this...

Code

---

-----------------------------------

 

$m=1;

$q=1;

 

while($row=mysql_fetch_assoc($q2)) {

 

$letime=$row['BidEndTime'];

$ledate=$row['BidEndDate'];

$lftime=$row['BidStartTime'];

$lfdate=$row['BidStartDate'];

  $lsampm=$row['sampm'];

 

$ledate=date("m/d/Y",strtotime($ledate));

$lfdate=date("m/d/Y",strtotime($lfdate));

 

  <div id="lclock<?php echo $q;?>" class="tdfont31" align="center">[clock<?php echo $q;?>]</div>

 

<div id="lclocka<?php echo $q;?>" class="redfont2" align="center"></div>

 

<script language="JavaScript">

 

  function AddTime(myDiv,dthen,dnow,add,no,bpk)

{

              if(bpk>0) {

  var dthen = new Date(dthen);

var dnow = new Date(dnow);

ddiff = new Date(dthen-dnow);

gsecs = Math.floor(ddiff.valueOf()/1000);

newsecs = gsecs + add;

    CountBack(myDiv, newsecs);

 

//var popUp1 = document.getElementById("lclocka"+no);

// popUp1.style.visibility = 'visible';

//popUp1.style.display = 'block';

 

    var popUp = document.getElementById("lclock"+no);

            popUp.style.visibility = 'hidden';

            popUp.style.display = 'none';

}

 

 

 

 

}

 

StartCountDown("lclock<?php echo $m;?>","<?php echo $ledate.' '.$letime.' '.$row['eampm'].' ';?>-0400","<?php echo $lfdate.' '.$lftime.' '.$row['sampm'].' ';?>-0400")

  //StartCountDown("clock1","06/27/2010 12:33 PM -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,ndate)

  {

 

    var dthen = new Date(myTargetDate);

    var dnow = new Date(ndate);

    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 = "%%H%%:%%M%%:%%S%%";

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";

//document.getElementById("loginchk").style.visibility="hidden";

 

 

}

  }

 

 

</script>

?>

<form id="feedForm" name="feedForm" method="post" action="">

  <input name="image" type="image" id="loginchk<?php echo $m;?>" onclick=" AddTime('lclocka<?php echo $m;?>','<?php echo $ledate.' '.$letime.' '.$row['eampm'].' ';?>-0400','<?php echo $lfdate.' '.$lftime.' '.$row['sampm'].' ';?>-0400', '20','<?php echo $q;?>','<?php echo $bpk;?>'); return false;"

</form >

<?php

$m++;

$q++;

 

}

Link to comment
https://forums.phpfreaks.com/topic/164744-time-countdown-problem/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.