getAnswerDesc()

The getAnswerDesc() function (client-side) retrieves either the description of a specific answer or the description of the first selected answer for a question. The description matches the value in the Description field on the answer record.

Syntax

Use these syntax formats for the getAnswerDesc() function:

  • To retrieve the description of the first selected answer for a question, use:

                    getAnswerDesc('QUESTION_CODE'); 
    
                  
  • To retrieve the description of a specific answer, use:

                    getAnswerDesc('QUESTION_CODE/ANSWER_CODE'); 
    
                  

Return Value

The getAnswerDesc() function returns the answer description as a string.

            'Description' 

          

Parameters

Note:

Either the question code or the combination of question and answer codes is required.

The getAnswerDesc() function accepts the following parameters:

  • QUESTION_CODE (string) - Specifies the code of the question to which the answer belongs.

  • QUESTION_CODE/ANSWER_CODE (string) - Specifies the combination of question and answer codes that identifies the answer. You can find the codes in the Code field on the corresponding records.

Examples

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

Retrieving a Specific Answer Description

This example retrieves the description associated with the answer having code BEIGE, which belongs to the question with DESK as a code.

              const description = getAnswerDesc('DESK/BEIGE');
console.log(description); 

            

The returned description may look like this:

              Desktop with the beige top surface 

            

Retrieving the Description for the First Selected Answer

The example retrieves the description associated with the first selected answer for the "Select color" question having COLOR as a code.

              const description = getAnswerDesc('COLOR');
console.log(description); 

            

Suppose the question has the following answers:

  1. Blue (code BLUE)

  2. Beige (code BEIGE)

  3. Gray (code GRAY)

If a user selects "Gray" and "Beige", the returned may be:

              Desktop with the gray top surface 

            

Related Topics

General Notices