Jump to content

Help with countdown function


Hobbyist_PHPer

Recommended Posts

Hi, I have a JQuery script that I am using part of, partially, and I could use some help with it... Right now it counts down and displays in seconds, I am hoping someone can show me how to make it display in minutes and seconds... Then the next function in it is a submit form function... that's the part that I'm not currently using, but need to for the next step... So, here's what I have...

 

            if ($row['CallTaken'] == "No")
            {
        ?>
                <script>
                    $(function() {
                    var seconds = 600;
                    setTimeout(updateCountdown, 1000);

                    function updateCountdown() {
                        seconds--;
                        if (seconds > 0) {
                            $("#countdown").text("You have " + seconds + " seconds remaining");
                            setTimeout(updateCountdown, 1000);
                        } else {
                            submitForm();
                        } 
                    }
                    });
                    // Here the operator has not answered the call within 10 minutes, need to take action...
                    function submitForm() {
                    document.forms[0].submit();
                    }
                </script>
        <?
            }
            else 
            {
            ?>
                <script>
                    $(function() {
                    $("#countdown").text("You have accepted the call.");
                    });
                </script>
            <?
            }

 

The submit form section, I would like to know if that would allow me to put a hidden form in the page, name or id it, and then have that function submit it?

Link to comment
https://forums.phpfreaks.com/topic/262643-help-with-countdown-function/
Share on other sites

minutes = math.floor( seconds/60 );
countseconds = seconds % 60;
text = "You have " + minutes + ":" + ( countseconds < 10 ? "0" : "" ) + countseconds + " remaining.

 

I appreciate your response, and it would seem that your code should work, but so much as even adding the minutes variable anywhere, breaks the function.

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.