Adding timing question prevents javascript NextButton/PreviousButton click functionality | XM Community
Solved

Adding timing question prevents javascript NextButton/PreviousButton click functionality

  • 15 April 2019
  • 2 replies
  • 10 views

Badge +1
We've implemented a data collection survey that has several sections: shallow/deep, fresh/salt. This means that certain sites will skip questions depending on the site. The questions are grouped by block, and we use javascript to fill in unused responses and skip the unused blocks. For example, a shallow site will not be shown the deep questions.

At the end of the survey, we present a summary of the entered and automatically filled in data for the user to compare to the postcard that was filled out during sampling and testing. There is a yes/no question that asks if the postcard and the screen data match. When the user clicks 'No', the next button is disabled and clicking the previous button uses javascript to jump through all the blocks back to the starting block of the questions.

This all works until we put in a timing question. Now the javascript will not automatically jump over an unused block. It will fill in the null responses correctly. Manually clicking the previous button brings the user to the previous page as it should. Unused blocks are not automatically skipped, and the user must click next to proceed.

Any thoughts on why $('NextButton').click(); or $('PreviousButton').click(); stops working with the timing question?
icon

Best answer by TomG 15 April 2019, 19:56

View original

2 replies

Userlevel 7
Badge +27
Try deferring the Next button click until the stack clears:
```
setTimeout(function() { jQuery("#NextButton").click(); },0);
```

Also, make sure your script is in addOnReady and not addOnload, and make sure page transition is set to None.
Badge +1
Many thanks @TomG. Never would have guessed this. Getting the survey to jump back to the start was the easy part.

Leave a Reply