Predefine Answers
You can set a question's defaultValue
, which will be used until a proper value
is specified by a user or programmatically. If the proper value
is never specified, defaultValue
is saved in the survey results.
const surveyJson = {
"elements": [{
"name": "subscribed",
"type": "checkbox",
"title": "I agree to receive weekly newsletters"
"defaultValue": true
}]
}
You can set the question value
property or call the Survey's setValue(questionName, newValue)
method to change the value at any point in your application:
import { Model } from "survey-core";
const survey = new Model(surveyJson);
survey.setValue("subscribed", false);