How can I call ajax function inside while loop for time countdown code

Discussion in 'PHP' started by ash007, Jul 9, 2009.

  1. #1
    Hi all,

    i have Auction time countdown.It's working fine.But I want to update the auction status with E when the time reaches zero.For that I call one ajax function (ended_time('E','<?php echo $m;?>','<?php echo $lplid;?>');)inside while loop.This function is updating with last row only not with corresponding id.

    Here I included code...Thanks in advance

    -----------------
    <script language="JavaScript">


    StartCountDown("lclock<?php echo $m;?>","<?php echo $ledate.' '.$letime.' '.$row['sampm'].' ';?>-0400")
    StartCountDown("adddiv<?php echo $m;?>","<?php echo $ledate.' '.$letime.' '.$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)
    {
    var tt;
    var dthen = new Date(myTargetDate);
    var dnow = new Date("<?php echo $lfdate.' '.$lftime.' '.$row['eampm'].' ';?>-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 m=1;
    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)
    {

    <?php /*?>update_time(DisplayStr,'<?php echo $m;?>','<?php echo $lplid;?>');<?php */?>
    document.getElementById(myDiv).innerHTML = DisplayStr;
    tt=setTimeout("CountBack('" + myDiv + "'," + (secs-1) + ");", 990);
    }
    else
    {
    document.getElementById(myDiv).innerHTML = "Auction Over";
    ended_time('E','<?php echo $m;?>','<?php echo $lplid;?>');

    }

    <?php /*?>ended_time('E','<?php echo $m;?>','<?php echo $lplid;?>');<?php */?>
    }






    </script>
     
    ash007, Jul 9, 2009 IP
  2. Hannaspice

    Hannaspice Active Member

    Messages:
    77
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    91
    #2
    Hannaspice, May 30, 2011 IP