Note that there are some explanatory texts on larger screens.

plurals
  1. POCountdown javascript function with variable target date
    text
    copied!<p>Hello Guys and Gals, I am trying to have (1) a javascript countdown function (2) a countdown function that accepts a php variable target date(e.g. 4 seconds after the user clicks 'start') (3) an onclick() to run both the stopstart() and updateAlarmTime() functions.</p> <p>This is what I use for base code: <a href="http://stopwatch.onlineclock.net/" rel="nofollow">http://stopwatch.onlineclock.net/</a></p> <p>On my main php page I have:</p> <pre><code>&lt;script src="js/stopwatch.js" type="text/javascript"&gt;&lt;/script&gt; &lt;?php $alarmsecond2=4; ?&gt; &lt;form name='stopwatch'.... &lt;input type='button' onclick='stopstart()' onfocus='this.blur()' name='startstopbutton' id='startstopbutton' ... value='Start'&gt; &lt;/form&gt; </code></pre> <p>stopstart() works as written above, updateAlarmTime() works if I use pulldown select menus to set the time variable, e.g. $alarmsecond2, but I don't want that.</p> <p>I tried calling stopstart() and updateAlarmTime('') with one onclick(), but only stopstart executes. I also tried calling a function to call both stopstart() and updateAlarmTime() with onclick() but that also didn't work.</p> <p>In stopwatch.js I have:</p> <pre><code>function stopstart() { t[t[2]]=(new Date()).valueOf(); t[2]=1-t[2]; if (0==t[2]) { clearInterval(t[4]); t[3]+=t[1]-t[0]; document.getElementById("startstopbutton").value="Start"; document.getElementById('split').innerHTML+= (t[7]++)+' Stop: '+format(t[1]-t[0])+'&lt;br&gt;'; t[4]=t[1]=t[0]=0; disp(); firstsplitflag = 0; } else { document.getElementById("startstopbutton").value="Stop"; t[4]=setInterval(disp, 43); } //GA urchinTracker('http://stopwatch.onlineclock.net/conversions/stopstartbutton'); } function updateAlarmTime() { var hour1 = alarmhour1; var hour2 = ahour2; var minute1 = aminute1; var minute2 = aminute2; var second1 = asecond1; var second2 = asecond2; var second_10th = asecond_10th; var second_100th = asecond_100th; var second_1000th = asecond_1000th; alarmTime = (hour1 + hour2 + minute1 + minute2 + second1 + second2 + second_10th + second_100th + second_1000th); } </code></pre> <p>How do I accomplish my three objectives?</p> <p>Thanks for any help.</p>
 

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