Script: Triggers - Radio Question Response Displays Text Question

Answering a 'Radio Question' can display a follow-up 'Text Question' on the same page 


Background

You may want to have a Radio Question and a follow-up Text Question (open end) on the same page. The stipulation is you want the Text Question to appear once the Radio Question has been answered. This article will show you how to set this up.


Instructions

Step 1: 'Radio' Question
  1. Add your 'Radio Question' as needed
    1. See article: Standard Question: Radio items (Single Select)
  2. In the Overall Question Settings do the following:
    1. See article: Overall Question Settings
    2. Turn OFF the "Hide on submit if valid" setting. This will leave the question on the screen should the other questions on the page get an error message.
  3. Add the following code to the 'Source Code Editor' of the 'Footnote' field 
    1. See article: Source Code Editor
    2. Add the code below:
      <script>
      /* NOTE: REPLACE "Q2" WITH THE RADIO QUESTION NUMBER */
      /* NOTE: REPLACE "Q3" WITH THE TEXT QUESTION NUMBER */
      	jQuery(function()
      	{
      		if (!jQuery(".cm-question[data-qnum=Q2] input:radio").is(":checked"))
      		{
      			jQuery("#question-Q3").hide();
      		}
      		jQuery(".cm-question[data-qnum=Q2] input:radio").change(function()
      		{
      			/* NOTE: UPDATE THE FORMULA IN THE NEXT LINE BELOW WHICH WILL SHOW THE FOLLOW-UP */
      			if (jQuery(".cm-question[data-qnum=Q2] input:radio:checked").attr("data-name") == "1") 
      								{
      					jQuery("#question-Q3").show();
      				}
      			else
      			{
      				jQuery("#question-Q3").hide();
      				jQuery(".cm-question[data-qnum=Q3] textarea").val("");
      			}
      		});
      	});
      </script>
      		
Step 2: 'Text Fields' Question
  1. Add your 'Text Fields' as needed
    1. See article: Standard Question: Text Fields
  2. In the Overall Question Settings do the following:
    1. See article: Overall Question Settings
    2. Turn OFF the "Hide on submit if valid" setting. This will leave the question on the screen should the other questions on the page get an error message.
    3. Toggle off the 'Require a Response' option. This will allow you to get by the page without answering the open end question.
    4. You may also want to add a 'Custom Validation' in order to make sure the 'Text Fields' question is answered under the appropriate circumstances
      1. See article: Custom Validations
Did this answer your question? Thanks for the feedback There was a problem submitting your feedback. Please try again later.

Still need help? Contact Us Contact Us