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
  • tixeon's Avatar Topic Author
  • Offline
  • Senior Member
  • Senior Member
More
9 years 6 months ago #112262 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?
The topic has been locked.
  • tpartner
  • tpartner's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
9 years 6 months ago #112278 by tpartner
Assuming your question codes are "Q1" and "Q2"...

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.

File Attachment:

File Name: limesurvey...9-09.lss
File Size:25 KB




.

Cheers,
Tony Partner

Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
The topic has been locked.
  • tixeon
  • tixeon's Avatar Topic Author
  • Offline
  • Senior Member
  • Senior Member
More
9 years 6 months ago #112313 by tixeon
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.
The topic has been locked.
  • tpartner
  • tpartner's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
9 years 6 months ago #112338 by tpartner
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.
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.
The following user(s) said Thank You: tixeon
The topic has been locked.
  • tixeon
  • tixeon's Avatar Topic Author
  • Offline
  • Senior Member
  • Senior Member
More
9 years 6 months ago #112368 by tixeon
That worked perfectly, thank you so much!!
The topic has been locked.

Lime-years ahead

Online-surveys for every purse and purpose