How to code a button so it will go to different quiz slides each time it is clicked – GRRR
April 25, 2025
How to code a button so it will go to different quiz slides each time it is clicked – GRRR
April 25, 2025

I have tried various scripts and interactions and I cannot get it to work.  When I use interactions  with a quizCounter variable (assigning a new number for each interaction) it ignores the conditions and simply takes me to the last quiz slide on the list.

I have tried various edits with JavaScript, including slide delays, and button won’t open any slides: Example:

var cpAPI = window.cpAPIInterface;
var index = parseInt(cpAPI.getVariableValue(“quizCounter”));

var quizSlides = [
1, 2, 3, 4, 5, 6, 7, 8, 9, 10,
11, 12, 13, 14, 15, 16, 17, 18, 19, 20,

];

console.log(“Current quizCounter value: ” + index);

if (index < quizSlides.length) {
console.log(“Navigating to quiz slide with index: ” + quizSlides[index]);
cpAPI.setVariableValue(“quizCounter”, index + 1);

setTimeout(function() {
cpAPI.call(“gotoSlide”, quizSlides[index]); // Using call() method to invoke gotoSlide
console.log(“Navigation completed to slide: ” + quizSlides[index]);
}, 300);
} else {
console.log(“All quizzes completed. Resetting to start…”);
cpAPI.setVariableValue(“quizCounter”, 1);

setTimeout(function() {
cpAPI.call(“gotoSlide”, quizSlides[0]); // Reset to first quiz slide
console.log(“Navigated to first quiz slide: ” + quizSlides[0]);
}, 300);
}

I am not a coder so I also tried working in ChatGPT and after hours of tries and reviewing the inspection panel, this is what it came up with (see image).

Anyone have an idea to help me get it to work?

All Comments
Sort by:  Most Recent
2025-04-29 02:17:19
2025-04-29 02:17:19

Hi Tonyette,

We do not have expertise writting code on buttons. Suggest you to to use default buttons on the quiz slides which will automatically go to next quiz slide slide after answering the questions.

 

Thanks,

Adobe Support

 

Like
(1)