Hello,
I'm not really a javascript developer I'm a PHP developer but I have a problem I am trying to figure out. I have an online test I need to build with a 30 minute timer. It is written in PHP but i was hoping to user a Javascript timer and carry it over through form submissions.
Basically my question is, can i feed a PHP variable into javascript? When my page first loads i have the PHP calculating the time plus 30 mins:
I then want to carry it through 30 questions and display on screen using this javascript:PHP Code:$target = date("m/d/Y H:i:s", time()+1800);
The problem I am having is this line: TargetDate = "<?php echo $target; ?>";Code:<script language="JavaScript"> TargetDate = "<?php echo $target; ?>"; BackColor = "palegreen"; ForeColor = "navy"; CountActive = true; CountStepper = -1; LeadingZero = true; DisplayFormat = "%%M%% : %%S%% "; FinishMessage = "Time is up!"; </script>
It accepts the date entered manually but not the dynamic date per the variable. Is there a way to make this work? I've written dynamic javascript before using PHP but for some reason this is giving me problems.
Thanks.
UPDATE: An idea occurred to me while I was writing this. I answered my own question. I made the PHP code produce the javascript and it worked.




Bookmarks