The dvalue
(default value) tag sets a value to a question or variable when the page loads. For respondent-facing questions, they can either accept the default response and proceed to the next page, or select a different response.
INCENTIVE. Incentive amount
translate: n
invisible: y
dvalue: 2
type: radio
1. $10
2. $15
The dvalue
tag sets simple default values when the page loads. However, the newer cvalue
and onload
tags offer more flexibility and are generally preferred over the dvalue
tag.
Details
- Add the
dvalue
tag directly on a question or variable to set a default value for that widget. - The
dvalue
tag accepts various inputs, including logical statements, mathematical expressions, Perl expressions, list functions, and other methods.
- If you're using the
type: radio
tag for your question, you can addinvisible: y
to hide it from the respondent if needed.
Tip! If you want to set a value to a question on page submission instead of page load, try the cvalue
tag instead.
Additional examples
Adding a default value to slider and radio slider questions
When adding the dvalue
tag to a slider or radio slider question, it specifies a starting position for the "thumb" or cursor on the scale and sets the initial value for the question.
Slider question
When using the dvalue
tag on an open-ended slider question, input any whole number value as the default starting point.
1. How much would you be willing to spend on a new cellphone?
type: slider
prefix: $
label above: y
min: 0
max: 2000
step: 50
dvalue: 500
Radio slider question
When using the dvalue
tag on a closed-ended radio slider question, use the option ID as the input.
set list: SCALE
1. 1
2. 2
3. 3
4. 4
5. 5
2. How satisfied were you with your <b>previous</b> experience?
type: radio slider
optsfrom: SCALE
dvalue: 3
value display: y
labels above: y
width: 500
Preselecting an answer for a recontact survey
For recontact surveys, you can use get_answer
and allowsreadsfrom
to pull in data from the original survey. For instance, if the color "violet" was missing from Q5 in the main survey, you can re-ask the question including "violet" while showing each respondent's original answer as the default selection. In Q5RC, pairing the dvalue
tag with get_answer
sets the previous response as the default, allowing respondents to keep or change their answer.
app config allowreadsfrom: originalsurveyID
... 5RC. This will show the answer selected at Q5 in the main survey called "originalsurveyID" as long as the SAME RESPONDENT ID is used. type: radio dvalue: get_answer('Q5', appid => 'originalsurveyID') 1. red 2. orange 3. yellow 4. green 5. blue 6. indigo 7. violet
To ensure the example above works correctly, certain tags must be applied to the app config
widget in both the main and recontact surveys. For details on the required setup, review the full example in the allowreadsfrom article.
Comments
0 comments
Please sign in to leave a comment.