- Posts: 78
- Thank you received: 2
Welcome to the LimeSurvey Community Forum
Ask the community, share ideas, and connect with other LimeSurvey users!
Insert other specify text into subquestion text of later question
- tixeon
- Topic Author
- Offline
- Senior Member
Less
More
9 years 7 months ago #112262
by tixeon
Insert other specify text into subquestion text of later question was created by tixeon
I am sure this is really simple, but I am having trouble finding the instructions.
Here is what I am trying to do:
Q1 blah blah blah?
[multiple response]
>option 1
>option 2
>option 3
>other specify ____________
Q2 blah blah blah?
[array question set to only feed through those selected in Q1]
>option 1
>option 2
>option 3
>other - <insert text from freeform box in Q1>
So how do I insert the text in Q2?
Here is what I am trying to do:
Q1 blah blah blah?
[multiple response]
>option 1
>option 2
>option 3
>other specify ____________
Q2 blah blah blah?
[array question set to only feed through those selected in Q1]
>option 1
>option 2
>option 3
>other - <insert text from freeform box in Q1>
So how do I insert the text in Q2?
The topic has been locked.
- tpartner
- Offline
- LimeSurvey Community Team
Less
More
- Posts: 10115
- Thank you received: 3597
9 years 7 months ago #112278
by tpartner
Cheers,
Tony Partner
Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
Replied by tpartner on topic Insert other specify text into subquestion text of later question
Assuming your question codes are "Q1" and "Q2"...
In Q2, add a sub-question with code "othercbox". The text for this sub-question is:
Here's a working survey.
.
In Q2, add a sub-question with code "othercbox". The text for this sub-question is:
Code:
Other: {Q1_other}
Here's a working survey.
.
Cheers,
Tony Partner
Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
Attachments:
The topic has been locked.
- tixeon
- Topic Author
- Offline
- Senior Member
Less
More
- Posts: 78
- Thank you received: 2
9 years 7 months ago #112313
by tixeon
Replied by tixeon on topic Insert other specify text into subquestion text of later question
Thank you! Is there a way to make the Other in Q2 only appear if it is selected in Q1?
This method it appears as a row option in Q2 even if it isn't selected in Q1.
This method it appears as a row option in Q2 even if it isn't selected in Q1.
The topic has been locked.
- tpartner
- Offline
- LimeSurvey Community Team
Less
More
- Posts: 10115
- Thank you received: 3597
9 years 7 months ago #112338
by tpartner
Cheers,
Tony Partner
Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
Replied by tpartner on topic Insert other specify text into subquestion text of later question
Ah, in 2.05 you cannot use "other" as a sub-question code so we'll have to work around it with a hidden option in Q1 and a little JavaScript.
1) Add a new sub-question to Q1 with code "myOther" (we'll hide this with JS).
2) Change the code of the "Other" sub-question in Q2 to "myOther". Its display is now filtered by our new option in Q1.
3) Add the following script to the source of Q1. It will hide the new option and togggle it depending on the state of the "Other" checkbox.
Here's the survey again with these changes.
1) Add a new sub-question to Q1 with code "myOther" (we'll hide this with JS).
2) Change the code of the "Other" sub-question in Q2 to "myOther". Its display is now filtered by our new option in Q1.
3) Add the following script to the source of Q1. It will hide the new option and togggle it depending on the state of the "Other" checkbox.
Code:
<script type="text/javascript" charset="utf-8"> $(document).ready(function(){ // Identify this question var thisQuestion = $('#question{QID}'); var thisOther = $('input.checkbox[id$="othercbox"]', thisQuestion); var thisOtherText = $('input.text[id$="other"]', thisQuestion); var otherToggle = $('input.checkbox[id$="myOther"]', thisQuestion); // Hide the "toggle" option $(otherToggle).closest('li.question-item ').hide(); // Listeners on the inputs $(thisOther).change(function(e) { handleOther(); }); $(thisOtherText).on('change keyup', function(e) { handleOther(); }); // A function to check the "toggle" option depending on the state od "Other" function handleOther() { $(otherToggle).prop('checked', $(thisOther).prop('checked')); checkconditions($(otherToggle).attr('value'), $(otherToggle).attr('name'), $(otherToggle).attr('type')) } }); </script>
Here's the survey again with these changes.
Cheers,
Tony Partner
Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
Attachments:
The following user(s) said Thank You: tixeon
The topic has been locked.
- tixeon
- Topic Author
- Offline
- Senior Member
Less
More
- Posts: 78
- Thank you received: 2
9 years 7 months ago #112368
by tixeon
Replied by tixeon on topic Insert other specify text into subquestion text of later question
That worked perfectly, thank you so much!!
The topic has been locked.