This script will dynamically change the maximum value allowed for a Numeric question, depending on what was previously entered for another Numeric question.
Example
The respondent enters "25" for the first Numeric question, then at the second Numeric question, the respondent will only be allowed to enter values in the range of 0-25.
Detailed Steps
Adding and setting up the questions:
- Open Power Survey Authoring.
- Click the Questionnaire tab of your study.
- Create your first Numeric question as required.
- Create your second Numeric question.
- Optional: set the Minimum value field, or choose to leave it blank (if blank, the default is 0).
Prepare the script in Notepad:
- Open a text editing tool such as Notepad.
- Copy the script below into Notepad.
- Change NUMERIC_2 to the name of your second Numeric question.
- Change NUMERIC_1 to the name of your first Numeric question.
- Copy the completed script from Notepad.
- Select the second Numeric question in the Questionnaire Tree.
- In the Scripting section of the second Numeric question, click Edit Scripts.
- Paste the script into the On Load tab.
- Click Save.
- Validate and test your survey.
Script:
/* Script Name: How do I ensure the value entered in a Numeric question does not exceed 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. */ NUMERIC_2.MaximumValue = NUMERIC_1.IntValue;
Comments
0 comments
Article is closed for comments.