Use an answer to prefill another answer

More
7 years 3 months ago #83167 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'

Please Log in or Create an account to join the conversation.

LimeSurvey Partners
More
7 years 3 months ago - 7 years 3 months ago #83174 by TMSWhite
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:
{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: 7 years 3 months ago by TMSWhite.

Please Log in or Create an account to join the conversation.

More
1 month 1 week ago #188757 by gordonc123
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

Please Log in or Create an account to join the conversation.

More
1 month 1 week ago #188758 by Joffm
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

Please Log in or Create an account to join the conversation.

More
1 month 6 days ago #188776 by gordonc123
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

Please Log in or Create an account to join the conversation.

More
1 month 5 days ago #188780 by Joffm
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

Please Log in or Create an account to join the conversation.

Start now!

Just create your account and start using Limesurvey today.

Register now
Join our Newsletter!