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

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

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