Randomising elements using JavaScript

Randomising elements using JavaScript

Randomisation of elements in the survey using JavaScript for custom randomisation logic.

A step-by-step interactive tutorial on randomising elements using javascript in SurveyEngine. Preview the live tutorial, then download and upload it to your account to examine the construction.

Tutorials

What this tutorial covers

Randomisation of elements in the survey using JavaScript for custom randomisation logic.

Each page of the tutorial demonstrates a specific technique. Work through it as a respondent first, then open the editor to see how it was built.

What you will learn

After completing this tutorial you will be able to implement randomising elements using javascript in your own SurveyEngine surveys.

Download the tutorial ZIP and upload it to your account to use it as a starting point or template for your own work.


Step-by-step walkthrough

Step 1: Understand when JavaScript randomisation is needed. Built-in randomisation handles most cases, but JavaScript gives you full control.

Step 2: Add a JavaScript block. Insert a JavaScript execution block on the page where randomisation should occur.

Step 3: Write the randomisation script. Use standard JavaScript array shuffle techniques to reorder DOM elements.

Step 4: Target elements by class or ID. Identify the elements to be randomised using consistent CSS classes or IDs.

Step 5: Store the randomisation order. Save the randomisation order to a hidden variable for export with the response data.

Try the live tutorial

The live tutorial is a working SurveyEngine survey. Click through it as a respondent to see the finished result.

Then download the tutorial ZIP file and upload it to your SurveyEngine account to examine how it was built.

Preview the live tutorial or download the ZIP file to load it into your account.


References


Ready to try it? Open a free SurveyEngine account, download the tutorial ZIP and upload it to your account.

Monthly. Annual. Procurement Friendly.
No obligation · 30-minute call

Or Contact us at support@surveyengine.com — we're glad to help.


Related articles


Scroll to Top