|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
javascript timer in php quiz
i have seen many quiz system using javascipt to show user how long they take the quiz.
i just imagine is it possible implement it in php since variable in javascript not in $, just the name, how to pass it to php script like quiz, so after they take quiz page said: congratulation, it's only takes 1 minute and 23 second . i have search in manual on how to do that using time(), $timestart=time(); code .... $timeend=time(); $used_time=$timestart-$timeend; $used_time=date('m:s',$used_time); but by echo $used_time it just give me strange result, even i take long time or shor time only result not far range between 01:23-01:35. how to track time use by user to complete quiz , is it done by php or javascript ? like http://www.ewebquiz.com/ which is written in asp. any hint are appreciate thanks, |
|
#2
|
||||
|
||||
|
Hi,
The code you have found should work, the problem is how you implement that code into your system, simply putting it all into one page will not work because PHP is server side, so the page is called, the code is processed and the results sent back to the browser, try implementing it in the following way: PHP Code:
Now get the user to fill out the quiz etc and send the results to a second page, include in the form a hidden value like so PHP Code:
Then in the page that checks the data of the quiz put the following code: PHP Code:
That should give you a more accurate reading. HTH
__________________
--------------------- -- SilkySmooth -- --------------------- Proxy | Little Directory |
![]() |
| Viewing: Dev Shed Forums > Web Design > JavaScript Development > javascript timer in php quiz |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|
|