Saving Survey Results and Advancing

Your Web View step can return a single answer, which will be saved in the survey results. This is done with the Complete a Web View Step method of the MyDataHelps.js SDK:

MyDataHelps.completeStep(answer);

This requires your Web View steps to include the MyDataHelps.js SDK. See the JS SDK Getting Started page for more details.

Answer Format

Answers from Web View steps are always saved as strings. Numbers, booleans, and complex objects are run through JSON.stringify() prior to being saved.

Advancing to the Next Step

Submitting an answer also continues to the next survey step. You can even call completeStep with no answer to advance without providing a specific value. The system will save an empty string as the survey answer in that case.

Normal navigation/branching rules can be set within MyDataHelps Designer, allowing you to skip a Web View step or advance to specific steps based on previous results.

Example

In this example, there is a single text box with an ID of “answer” where the user inputs their answer, and a “Continue” button that saves the answer and advances to the next step.

The script code gets the answer from the text box and then submits it as the step’s answer result.

Completing a Web View Step
<input id="Answer" type="text" placeholder="Test" />
<button onclick="postAnswer()">Continue</button>
<script>
function postAnswer() {
  var answerInput = document.getElementById("Answer");
  var answer = answerInput.value;
  MyDataHelps.completeStep(answer);
}
</script>
<input id="Answer" type="text" placeholder="Test" /> <button onclick="postAnswer()">Continue</button> <script> function postAnswer() { var answerInput = document.getElementById("Answer"); var answer = answerInput.value; MyDataHelps.completeStep(answer); } </script>

Populating Custom Fields and Demographics

You can store the answer from a Web View step into a custom field or demographic field using MyDataHelps Designer, just as you can for any other step type. See Populating Participant Fields.