Hi there,
I'm trying to write custom code to overwrite the responses from previous questions. Near the end of our survey, I use piped text to display responses from earlier in the survey. I only want to overwrite these responses after displaying them at the end of the survey, but before they are recorded. I want to do this using javascript/jquery at the end of the survey to avoid the complexity of setting embedded data fields for each individual question.
Ideally, the process would be something like this: use the QID of questions from previous blocks to access the responses. Then, change the values that respondents gave, but only at the very end of the study; this is why the responses cannot be overwritten or deleted on the page immediately after the respondent leaves the page.
I know we can used piped text to display text from previous questions/responses; how can I modify those previous responses?
Here's what I've tried before:
1) Setting a variable to
`${q://QID3/ChoiceGroup/SelectedChoices`
and then setting that variable to a different string, but I think it doesn't work because it's only a reference.
2) Overwriting QID22's responses with "hello" using jQuery like so
`jQuery("#"+"QID22"+".ChoiceTextEntryValue").val("hello");`
but this only returned an empty string when we accessed
`"${q://QID22/ChoiceTextEntryValue}"`
Any advice on how to accomplish this would be greatly appreciated. Thanks.
Page 1 / 1
@weim,
It can't be done. Those answers are stored with the response data when the respondent clicks 'Next'.
It can't be done. Those answers are stored with the response data when the respondent clicks 'Next'.
@TomG
Hmmm, still working on this. I'm thinking that maybe my solution would be to save the selected choice for each question in embedded data on each page. Then, delete the response so that it isn't saved -- all of this would be before the next button is clicked.
I have a few of the pieces: I think we will need to use
`Qualtrics.SurveyEngine.addOnPageSubmit`
and I've also been trying to use
`var ans="${q://QID3/ChoiceGroup/SelectedChoices}";`
Hmmm, still working on this. I'm thinking that maybe my solution would be to save the selected choice for each question in embedded data on each page. Then, delete the response so that it isn't saved -- all of this would be before the next button is clicked.
I have a few of the pieces: I think we will need to use
`Qualtrics.SurveyEngine.addOnPageSubmit`
and I've also been trying to use
`var ans="${q://QID3/ChoiceGroup/SelectedChoices}";`
and
`Qualtrics.SurveyEngine.setEmbeddedData('Q3', ans); `
What is the best way to save a text entry or multiple choice response to embedded data and then delete it before the page is submitted?
`Qualtrics.SurveyEngine.setEmbeddedData('Q3', ans); `
What is the best way to save a text entry or multiple choice response to embedded data and then delete it before the page is submitted?
> @weim said:
> and
> `Qualtrics.SurveyEngine.setEmbeddedData('Q3', ans); `
>
> What is the best way to save a text entry or multiple choice response to embedded data and then delete it before the page is submitted?
I'm not quite sure what you are trying to do, but two tips that might be helpful:
1. If you never define the embedded data variable in the survey flow, it will be available throughout the survey, but won't be saved in the response data.
2. If you just need to use a variable on a single page, just use a JavaScript variable. There is no need to save it as an embedded variable (actually, it is pointless).
> and
> `Qualtrics.SurveyEngine.setEmbeddedData('Q3', ans); `
>
> What is the best way to save a text entry or multiple choice response to embedded data and then delete it before the page is submitted?
I'm not quite sure what you are trying to do, but two tips that might be helpful:
1. If you never define the embedded data variable in the survey flow, it will be available throughout the survey, but won't be saved in the response data.
2. If you just need to use a variable on a single page, just use a JavaScript variable. There is no need to save it as an embedded variable (actually, it is pointless).
1) Ah yes, I forgot to mention that I have defined the embedded data in the survey flow.
2) I need to display the respondent's selected answer choice later in the survey (in another block), but I don't want it to be actually saved by Qualtrics as part of the final survey response. So I would like to temporarily save some of the respondent's answers in the embedded data for the duration of the survey and then clear it out before the survey is complete.
So far, I've tried to save the selected response to embedded data with "${q://QID3/ChoiceGroup/SelectedChoices}" and setting with setEmbeddedData, but it doesn't seem to be getting the values correctly. I'm also wondering how to save and delete embedded data with JavaScript?
Thanks so much @TomG!
2) I need to display the respondent's selected answer choice later in the survey (in another block), but I don't want it to be actually saved by Qualtrics as part of the final survey response. So I would like to temporarily save some of the respondent's answers in the embedded data for the duration of the survey and then clear it out before the survey is complete.
So far, I've tried to save the selected response to embedded data with "${q://QID3/ChoiceGroup/SelectedChoices}" and setting with setEmbeddedData, but it doesn't seem to be getting the values correctly. I'm also wondering how to save and delete embedded data with JavaScript?
Thanks so much @TomG!
> @weim said:
> So far, I've tried to save the selected response to embedded data with "${q://QID3/ChoiceGroup/SelectedChoices}" and setting with setEmbeddedData, but it doesn't seem to be getting the values correctly. I'm also wondering how to save and delete embedded data with JavaScript?
There really isn't any advantage to saving question answers (i.e. "${q://QID3/ChoiceGroup/SelectedChoices}") as embedded data because anywhere you would use the embedded data field, you could use the piped question answer. Also, you can't pipe an answer on the same page (i.e. you can't pipe the answer of QID3 on the same page where QID3 is displayed), you would have to use JavaScript to find the answer then take appropriate action. You can't delete embedded data, but if you don't declare it the survey flow, it won't be saved in the response data.
> So far, I've tried to save the selected response to embedded data with "${q://QID3/ChoiceGroup/SelectedChoices}" and setting with setEmbeddedData, but it doesn't seem to be getting the values correctly. I'm also wondering how to save and delete embedded data with JavaScript?
There really isn't any advantage to saving question answers (i.e. "${q://QID3/ChoiceGroup/SelectedChoices}") as embedded data because anywhere you would use the embedded data field, you could use the piped question answer. Also, you can't pipe an answer on the same page (i.e. you can't pipe the answer of QID3 on the same page where QID3 is displayed), you would have to use JavaScript to find the answer then take appropriate action. You can't delete embedded data, but if you don't declare it the survey flow, it won't be saved in the response data.
> @TomG said:
> You can't delete embedded data, but if you don't declare it the survey flow, it won't be saved in the response data.
Ohhh, interesting, this seems like part of my solution then!
In a previous post, you mentioned that answers are stored with response data once the respondent clicks the Next button. Is it possible to reset question answers with JavaScript after the respondent clicks the Next button, but *before* it's saved? Ideally, I'd like to save the respondent's answer in embedded data (so that it can be piped in at the end of the survey), but also delete the question answer on the page -- something like, set "${q://QID3/ChoiceGroup/SelectedChoices}" to be an empty string or string of random characters. So at the end of the survey, the respondent's answers won't be saved with embedded data (because they weren't declared), nor with the regular response data?
> You can't delete embedded data, but if you don't declare it the survey flow, it won't be saved in the response data.
Ohhh, interesting, this seems like part of my solution then!
In a previous post, you mentioned that answers are stored with response data once the respondent clicks the Next button. Is it possible to reset question answers with JavaScript after the respondent clicks the Next button, but *before* it's saved? Ideally, I'd like to save the respondent's answer in embedded data (so that it can be piped in at the end of the survey), but also delete the question answer on the page -- something like, set "${q://QID3/ChoiceGroup/SelectedChoices}" to be an empty string or string of random characters. So at the end of the survey, the respondent's answers won't be saved with embedded data (because they weren't declared), nor with the regular response data?
> @weim said:
> In a previous post, you mentioned that answers are stored with response data once the respondent clicks the Next button. Is it possible to reset question answers with JavaScript after the respondent clicks the Next button, but *before* it's saved? Ideally, I'd like to save the respondent's answer in embedded data (so that it can be piped in at the end of the survey), but also delete the question answer on the page -- something like, set "${q://QID3/ChoiceGroup/SelectedChoices}" to be an empty string or string of random characters. So at the end of the survey, the respondent's answers won't be saved with embedded data (because they weren't declared), nor with the regular response data?
Sure, you can do it in an addOnPageSubmit function. The method will vary based on the question type.
> In a previous post, you mentioned that answers are stored with response data once the respondent clicks the Next button. Is it possible to reset question answers with JavaScript after the respondent clicks the Next button, but *before* it's saved? Ideally, I'd like to save the respondent's answer in embedded data (so that it can be piped in at the end of the survey), but also delete the question answer on the page -- something like, set "${q://QID3/ChoiceGroup/SelectedChoices}" to be an empty string or string of random characters. So at the end of the survey, the respondent's answers won't be saved with embedded data (because they weren't declared), nor with the regular response data?
Sure, you can do it in an addOnPageSubmit function. The method will vary based on the question type.
Leave a Reply
Enter your E-mail address. We'll send you an e-mail with instructions to reset your password.