Explore the community Forums Lectora Lectora Questions & Answers Javascript and HTMLNames Reply To: Javascript and HTMLNames

#383331 Score: 0
Profile photo of CarlFink
LUC16 Attendee
wise owl
curious george
friend finder
41 pts

Coming in very late, but this is highly relevant to what I’m trying to do now.

I asked a question recently about questions: Multiple choice/select questions: scripted access to CURRENT order on page? Apparently there’s no direct support in Lectora for this. I therefore need to script around the gap.

Could I put a Token Substitution snippet on each of the Choice nn text objects adding some unique string to their HTMLnames, say “choice”, and then in JavaScript parse the list of DOM objects on the page to get an array (or better structure?) of pointers to the labels for each question choice? Or would it be simpler to just manually name each choice label from the Lectora developer interface, for every question in every quiz?

My final goal is to then sort the choice labels by Y position and be able to play audio clips reading each one aloud, in order by vertical position. The audio clips would be linked to each question choice and also would play if the item is clicked. (I would thus override the default behavior of selecting the appropriate radio button/checkbox when the label is clicked.)