Welcome to the LimeSurvey Community Forum

Ask the community, share ideas, and connect with other LimeSurvey users!

Use an answer to prefill another answer

  • amritdeep
  • amritdeep's Avatar Topic Author
  • Offline
  • Junior Member
  • Junior Member
More
11 years 9 months ago #83167 by amritdeep
Use an answer to prefill another answer was created by amritdeep
In limesurvey workaround i have found the code for
"Use an answer to prefill another answer"

<script>
<!--
function Custom_On_Load(){
document.getElementById('answer1000X11X30').value='{INSERTANS:1000X10X20}';
document.getElementById('answer1000X11X31').value='{INSERTANS:1000X10X21}';
}
-->
</script>



Please tell me where i have to copy this code so that answer of '1000X10X20' copy to 'answer1000X11X30'
The topic has been locked.
  • TMSWhite
  • TMSWhite's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
11 years 9 months ago - 11 years 9 months ago #83174 by TMSWhite
Replied by TMSWhite on topic Use an answer to prefill another answer
You can actually use Expression Manager to use one answer to set the value of another question, even if the other question is in another group (as is the case in your example).

Say your questions are 'a1' (1000X10X20), 'a2' (1000X10X21), 'b1' (1000X11X30), and 'b2' (1000X11X31), you would assign the values this way:
Code:
{b1=a1, b2=a2, ''}

This code could be put in a question or help text. Since it uses the comma operator, it returns the final value (''), so nothing will be displayed. You can also call this from either group 10 or group 11, although calling from group 11 will avoid having Expression Manager warn you of potential errors. Lastly, you don't need to put this within a <script>.

Some relevant documentation can be found here .
Last edit: 11 years 9 months ago by TMSWhite.
The topic has been locked.
More
4 years 7 months ago #188757 by gordonc123
Replied by gordonc123 on topic Use an answer to prefill another answer
Lets say I have 3 related limeSurvey questions where only one will have any content and the other two questions with no content (null) will be hidden...depending on which one matches the ID of a previous dropdown question.. So I wish to make a question further down the survey that will pull in the contents of the one of the 3 related questions that actually has content. How can I do this? Thanks, Gordon

Gordon Cantor
The topic has been locked.
  • Joffm
  • Joffm's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
4 years 7 months ago #188758 by Joffm
Replied by Joffm on topic Use an answer to prefill another answer
You should explain a little bit more clearly.
What types of question are involved?
And of course send an example (*.lss) with the relevant questions.

I understand:
First there is a single punch question (drop-down) ("Q1")
Three further questions (what type?) ("Q2", "Q3", "Q4") have a relevance equation depending on Q1, so that only one of them is displayed.
I assume these are questions of type "short text".
Now you want to pipe the content of ("Q2", "Q3", "Q4") into a question ("Q5").

This is quite simple, because two of the question do not have a content, they are empty.
{join(Q2,Q3,Q4)} should do it, meaning all three contents are joined. Because two of them are empty, only the filled content will be piped.

Joffm

Volunteers are not paid.
Not because they are worthless, but because they are priceless
The following user(s) said Thank You: gordonc123
The topic has been locked.
More
4 years 7 months ago #188776 by gordonc123
Replied by gordonc123 on topic Use an answer to prefill another answer
Thank you very much Joffm! That got the value I wanted into question ("Q5") - my issue now is how to get that same value automatically into the ANSWER for "Q5" - so when I export the survey responses (Excel or csv), the question 5 column will contain that value for that survey record.

Gordon Cantor
The topic has been locked.
  • Joffm
  • Joffm's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
4 years 7 months ago #188780 by Joffm
Replied by Joffm on topic Use an answer to prefill another answer
So use an question of type equation and pipe this question. You will get a column in the dataset, that contains the value.
Joffm

Volunteers are not paid.
Not because they are worthless, but because they are priceless
The following user(s) said Thank You: gordonc123
The topic has been locked.

Lime-years ahead

Online-surveys for every purse and purpose