Update Hidden Values if Answers Are Changed

By default, hidden values do not update when respondents go backwards in a survey and change their answers. One way to solve this problem is to remove the Back button on a survey, but that still doesn't ensure that they can't click Back on their browser. If you need to ensure that hidden values get updated, use this script.

The Script

Add a Custom Script action and copy and paste the following code.

  • Make sure the action is on a page that follows the question from which the hidden value pulls.
  • The hidden value must follow the script but it can be on the same page.

--[[Reset a hidden value when a respondent changes their answers.
Place this script above the hidden value you are changing (on the same page)
--]]

-- The merge code or codes that are going to be evaluated. This is usually the same merge code as that in the hidden value. Update the ID of the merge as needed.

mergeCode = '[question("value"), id="2"]'

-- The ID number of the hidden value you are changing. Update this ID number as needed.

hiddenValue = 4

---------- Be careful when editing below this line ----------

setvalue(hiddenValue, evaluatemergecodes(mergeCode))

Required Customizations

Change the IDs for the merge codes that are going to be evaluated and the ID of the hidden value.

Basic Standard Market Research HR Professional Full Access Reporting
Free Individual Team & Enterprise
Feature Included In