Note that there are some explanatory texts on larger screens.

plurals
  1. POpass parameter to javascript onload event from php
    primarykey
    data
    text
    <p>I have a javascript code for countdown. I have a date which I gather from database usu php, I need to pass the date object ot javascript function but I don't know how. I tried this:</p> <pre><code>&lt;body onload="countIt(&lt;?php echo $event-&gt;startDate;?&gt;)"&gt; </code></pre> <p>but it doesn't seem to work. here is the js code that I have</p> <pre><code>function countIt(date) { ///i will parse the date into below variables if I can get the date. year = 2013; month = 09; day = 28; hours = 12; minutes = 00; seconds = 00; setTimeout(function() { endDate = new Date(year, month, day, hours, minutes, seconds, 00); thisDate = new Date(); thisDate = new Date(thisDate.getFullYear(), thisDate.getMonth() + 1, thisDate.getDay(), thisDate.getHours(), thisDate.getMinutes(), thisDate.getSeconds(), 00, 00); var daysLeft = parseInt((endDate - thisDate) / 86400000); var hoursLeft = parseInt((endDate - thisDate) / 3600000); var minutsLeft = parseInt((endDate - thisDate) / 60000); var secondsLeft = parseInt((endDate - thisDate) / 1000); seconds = minutsLeft * 60; seconds = secondsLeft - seconds; minutes = hoursLeft * 60; minutes = minutsLeft - minutes; hours = daysLeft * 24; hours = (hoursLeft - hours) &lt; 0 ? 0 : hoursLeft - hours; days = daysLeft; startCount(days, hours, minutes, seconds); }, 1000); } function startCount(days, hours, minutes, seconds) { document.getElementById("counter").innerHTML = "DAYS " + days + ", HOURS " + hours + ", MINUTES " + minutes + ", SECONDS: " + seconds; countIt(); } </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload