This script will dynamically change the total amount to be allocated at an Allocation Slider question, depending on what was previously entered at a Numeric question.
Example
If the participant enters 25 at the Numeric question, then at the Allocation Slider question, the participant will only be allowed to allocate 25
Note: This script will not work for an Allocation Grid question.
Detailed Steps
Adding and setting up the Questions:
- Click on the Questionnaire tab of your survey.
- Create your Allocation Slider question (it must be at any point after the Numeric question which contains the allocation total value).
- Ensure that the Total to Allocate field in the properties of the Allocation Slider question is 100.
- Optional: Update the Units field in the properties of the Allocation Slider with the appropriate symbol depending on the context of the question.
Prepare the script in Notepad:
- Open Notepad or a similar text editing tool.
- Copy the script below into Notepad.
- Change ALLOC_SLIDER to the name of your Allocation Slider 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 slider 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_SLIDER; int val = NUMERIC_QUESTION.IntValue; gs.MinimumAllocatable = val; gs.MaximumAllocatable = val; gs.ExtensionData = gs.ExtensionData.Replace("100", ""+ val +"");
Insert the completed script into the Script section of your Allocation Slider Question:
- Copy the completed script from Notepad.
- Select the Allocation Slider Question in the Questionnaire Tree.
- In the Scripting section of the Allocation Slider Question, click Edit Scripts.
- Paste the script into the On Load tab.
- Click Save.
- Click Validate and test your survey.
More Information
Please click on the webhelp links below for more information:
Comments
0 comments
Article is closed for comments.