Zoltan
Zoltan

Reputation: 93

JQuery Timer with Php Variable

I have been browsing this site for along time to help me learn various parts of coding and found it most helpful. I am struggling much so with Jquery & PHP to a point I cannot find my answer.

I am probably asking it wrong. But I need to be able to use JQuery countdown timer function to use one of my PHP variables, when a button is clicked, if this is possible?

    <b><span style="color:red"><div id="Count"></div></span></b>
    <script type="text/javascript">

    $('#Count').countdown({until: '+0h +0m +15s', significant: 2,
        expiryText: '<div class="over"><h3>Finished</h3></div>',
    layout: '{d<}{dn} {dl} {d>}{h<}{hn} {hl} {h>}{m<}{mn} {ml} {m>}{s<}{sn} {sl}{s>}'}); 

<button>Start</button>
    </script>

This is my current JQ option, but automatically activates when I load the page. I require it to start when I click the button.

Also from the top you will see it uses 15 seconds. I have tried to replace it with my PHP variable which is

$count1

But this did not work :(

Any advice would be most helpful as JQ is a new language to me and I am struggling to start. Thanks for your time.

Upvotes: 1

Views: 127

Answers (1)

Luke
Luke

Reputation: 5104

<PHP echo $count1; ?>

Should work if you just stick it in where you would normally put the variable. It just echoes the value of count1 so whenever the client gets the JavaScript code the variable is just a number.

Upvotes: 2

Related Questions