How to use JavaScript in a questionnaire

Research Studio has two JavaScript functions that can be modified to allow users to program extra functionality into questionnaires. These scripts can be added to the questionnaire by adding the HTML element.

pageReady()

This function is called when the questionnaire page has completed loading. It can be used to run animations or videos once all the elements have been loaded onto the screen.

This script disables the answer and next buttons for 10 seconds while a video is playing.

validate()

A function called when the Previous or Next buttons are pressed. This function can be used to run complex validation scripts.

This script loops through a number of numeric rows on the screen and only allows the user to continue if the total equals 100.

jQuery


Research Studio has the jQuery JavaScript library available.

“jQuery is a fast and concise JavaScript Library that simplifies HTML document traversing, event handling, animating, and Ajax interactions for rapid web development.”

If you are familiar with using jQuery you can use the selectors and functions directly within scripts without loading the libraries in your script.

Further information on jQuery can be found at: http://jquery.com/ and http://jqueryui.com/