This script will dynamically change the total amount to be allocated in an Allocation Grid question, depending on what was previously entered in a Numeric question.
Example
If the participant enters 25 in the Numeric question, then in the Allocation Grid question, the participant will only be allowed to allocate 25
Note: This script will not work on an Allocation Slider question.
Detailed Steps
Adding and setting up the Questions:
- Click on the Questionnaire tab of your survey.
- Create your Allocation Grid question (it must be at any point after the Numeric question which contains the allocation total value).
- Ensure that the Minimum total and Maximum total fields in the properties of the Allocation Grid question are both 100.
- Update/delete the default instruction text of the Allocation Grid question.
Prepare the script in Notepad:
- Open Notepad or a similar text editing tool.
- Copy the script below into Notepad.
- Change ALLOC_GRID to the name of your Allocation Grid question.
- Change NUMERIC_QUESTION to the name of the Numeric question.
- Save the completed script in Notepad.
Script:
/* Script Name: How do I ensure the sum of an Allocation Grid question is equal to the value in a previous Numeric question? To ensure your script works as expected, always copy the original script from the script library found in the support portal. Failure to use the most up to date script from the script library may cause unexpected results. */ GridSequence gs = ALLOC_GRID; int val = NUMERIC_QUESTION.IntValue; gs.MinimumAllocatable = val; gs.MaximumAllocatable = val;
Insert the completed script into the Script section of your Allocation Grid Question:
- Copy the completed script from Notepad.
- Select the Allocation Grid Question in the Questionnaire Tree.
- In the Scripting section of the Allocation Grid Question, click Edit Scripts.
- Paste the script into the On Load tab.
- Click Save.
- Click Validate and test your survey.
More Information
Please visit the following links to our Webhelp to learn more about:
Comments
0 comments
Article is closed for comments.