Explore the community Forums Lectora Lectora Questions & Answers retrieving the timer value into a variable Reply To: retrieving the timer value into a variable

#419889 Score: 0
Profile photo of Darrel Somoza
Darrel Somoza
Member
contributor
friend finder
beginner
intermediate
junior moderator
advanced
wise owl
curious george
profile
209 pts
@Klaatu

Yes, you can grab the timer value. See attached. I prefer to use jQuery but it can be accomplished with vanilla JavaScript as well.

For most objects in Lectora you can get its HTML name by selecting the object going to Properties and then mouse over the little down arrow in the bottom right hand corner in the name box (where you can add a description). However, I find this is not always accurate. I prefer to open the project and use the browsers developers console. From your post, I feel you probably know your way around in there.

The Timer Object is really only for counting up or down and then performing an action when it completes. There is no reserved variable that holds the current timer object time. The timer object code seems to hold a start time number and last update number and from there calculates the time to pop into a span that displays it but its not assigned a variable you can grab. For this reason it is much easier to just grab the current contents of that span (as I did in the example) and do what you need with it from there. I hope I’m making sense. I need coffee…

Or you could use Math’s suggestion if that works better for you.

Attachments:
  1. TimerStuff.zip