Page flow and scripting can be used to hide or show an Other Specify text field when a respondent enters a specific value into a Numeric Grid row.
When following this tutorial, ensure that all your questions have ACCESS CODES. Use the following steps to get started:
- 1. In the survey designer, create a Numeric Grid question. When adding the question rows, ensure that each row has a TAG called CODE and a value for each TAG. Choose a row that will be used to hide or show the Other Specify question. In this example we will use the row called "Other".
- 2. Create a Single Line Text question, this will be used as the Other Specify text field. This question will be hidden or shown via page flow and scripting.
- 3. In the survey designer, add a new Javascript Script to the survey page. Use the "Execute Javascript for a Question specific Event". Select the Single Line Text question that was created in step 2. Select the "Execute Javascript to determine whether a Text/Number Page Flow should show a Question" event.
- 4. Add the following script that will test if a numeric value that is input into a specific Numeric Grid row is greater than zero. Example script:
//Get the question
var oNumber = wscScripting.getQuestionByDataPipingCode('GRID');
//Get the row
var oRow = wscScripting.getRowByTagValue(oNumber, 'CODE', 'OTHER');
//Test for if we show the Other text field
var bShowOther = false;
//Check if the question and row exist
if (oNumber && oRow) {
//Get the value for that row
var nValue = wscScripting.getMatrixRowNumericTotal(oNumber, oRow);
//Check if the value for that row is > 0
if (nValue > 0) {
//Show the Other Specify question
bShowOther = true;
};
};
args.isValid = bShowOther;
- 5. We can now setup the page flow. In your survey navigate to Design --> Survey Flow and click on the Create New Survey Flow icon. Under the Type of Flow heading, select the "Hide/Show Questions based on answers to questions on the same page" option. Choose the survey page containing the the Single Line Text question to be hidden and the Numeric Grid question that was created in the earlier steps. Choose the row and choice in the numeric grid that you want to trigger the hide/show event for the Single Line Text question.