Not loading the same - I am stumped as to why

I have a short Q & A system. Just to educate drivers on a specific schools requirements. Pretty basic system. Question comes up, you click on answer and then it show right or wrong and you can click to go to the next question. On all but between the 1st and 2nd questions the next questions answers all display at the same time. I cannot find any differences between questions. Here is a video with the issue.

It works fine, does not affect functionality, but am wondering why it does this or how to fix.

Here is url to temp location of full quiz.


Clarification: When question 2 comes up the middle answer comes up last. On all other questions they all show up at the same time on the screen.

Sorry not sure what we are supposed to be seeing as the issue.
Only see one green answer at a time if question wrong?

Clarification: When question 2 comes up the middle answer comes up last. On all other questions they all show up at the same time on the screen.

Ok I see what you mean. that is odd.. will see if I can figure its out.

Also the code is the same for every single question card. All that changed is the text and where the correct answer was placed. Of course each element has their own unique element id etc and no conflicts.

Again, it is not a big issue as it all functions fine but just “one of those things”….

It looks like there is a clash going on with your JS.

Probably the hidequestions() is hiding all the questions in the doc clashing with maybe the showquestions() ?

if you change the hidequestions() to this I think it will fix the issue.

var getscenename = document.getElementById(hypeDocument.currentSceneId());
var questionbox = getscenename.getElementsByClassName("ques");
var I;
for (i = 0; i < questionbox.length; i++) {
questionbox[i].style.display = "none";

Thanks. I will give that a shot.

I just uploaded a version with the change I made by adding the 1 to the end of the variable. It now works fine. A good example of not being able to see the forest for the trees.

1 Like

Which variable?

Where I had used the same variable more than once in different scripts rather than creating a new one. questionbox

Non eof you var names are global. They are only local to the individual script executions so having same names will not be an issue in how you have things set up.

The suggested change to hidequestions() , which you made, is making it work.

Yes I know that they are not global on local. So it was strange it make it work but anyway it works now. I am investigating further to find out why a simple change made it work.

I hate mysteries. LOL.

Honestly I

Me to.

So just to make a point of it and to help you and please forgive me if I misunderstand what you are saying..

The changes you made to the var names have made no difference. The only change that affects it is the

is this:

var questionbox = document.getElementsByClassName("ques");

to this

var getscenename = document.getElementById(hypeDocument.currentSceneId());
var questionbox[i] = getscenename.getElementsByClassName("ques");

Or to this

var questionbox = element.getElementsByClassName("ques");

This works because the scene object/element is used for the element when a timeline calls a script

1 Like

Also just to add you can get rid of the js for css display, which is mainly to stop people clicking twice by using the built in keyframe action to do this. I will PM you with this.