Originally posted by Ashish Kothari:
Urvi:
I also never tried this approach ,this is just a suggestion .
I was asked in interview ,what if javascript is disabled?then what to do?
Ashish
Originally posted by Ashish Kothari:
What if javascript is disabled by user?
You can make a timer bean,and get current time in mili seconds as well as elapsed time using System class methods.
give it a try ,I think this would be better approach.
Though script is ok,but try to do it with pure jsp would be better approach.
Ashish
Originally posted by Bear Bibeault:
That's a bit of a tough one since you're trying to impose real-time response on top of a protocol (HTTP) which is most definitely not real-time capable.
My initial thought is to use a frameset: one frame with the timer and one frame with the questions. The page loaded into the "timer frame" would perform the countdown using Javascript.
A variant: assuming you are concerned with modern browsers only, avoid the frameset (which are a thing to be avoided if at all possible) and create a page with an embedded iframe. The "master page" can control the timer, while the iframe is used to serve the question pages.
Problems arise with these approaches if the "timer page" gets refreshed. Perhaps the "end time" is saved on the server in the session so that the timer control page can pick up the correct remaining time regardless of refresh.
There are many other approaches, but one of the above (I prefer the iframe), is the first approach I'd give a try.
hth,
bear
[ May 30, 2003: Message edited by: Bear Bibeault ]
Originally posted by Christian Baron:
Another possible approach:
Let JavaScript write the remaining time in a hiddenfield or use as display an inputfield.
When an answer is submitted, you write it with JSP back to Javascript again. E.g.:
[ May 30, 2003: Message edited by: Christian Baron ]