reset()

The reset() function (client-side and server-side) clears a specific answer or clears all answers for a question. Use this function when you need to return a question or its answers to an unselected or blank state.

Note:

If you use this function in asynchronous code, call scopeRefresh(), scopeApply() or renderView() to apply the changes.

Syntax

Use these syntax formats for the reset() function:

  • To clear all answers to a question:

                    reset('QUESTION_CODE'); 
    
                  
  • To clear a specific answer:

                    reset('QUESTION_CODE','ANSWER_CODE'); 
    
                  

Return Value

The reset() function returns undefined.

Parameters

Note:

The question code is required.

The reset() function accepts the following parameters:

  • QUESTION_CODE (string) - Specifies the code of the question for which to clear a specific answer or all answers. You can find the code in the Code field on the question record.

  • ANSWER_CODE (string) - Specifies the code of the specific answer you want to clear. You can find the code in the Code field on the answer record. If omitted, all answers under the question are cleared.

Examples

The following examples show how to use the reset() function.

Resetting All Answers for a Question

This example clears all previously selected answers for the "Select desk type" question with code DESK_TYPE.

              reset('DESK_TYPE');
scopeRefresh(); 

            

Resetting a Specific Answer

The example clears the A1000 answer from the "Select desk type" question with the code DESK_TYPE.

              reset('DESK_TYPE', 'A1000');
scopeRefresh(); 

            

Related Topics

General Notices