Welcome to the LimeSurvey Community Forum

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

MyOther not working in hosted version

  • tixeon
  • tixeon's Avatar Topic Author
  • Offline
  • Senior Member
  • Senior Member
More
5 years 10 months ago #168949 by tixeon
I am using the MyOther script in a local install version of limesurvey (Version 2.6.7-lts Build 171212) and it is working fine. I just imported the survey to the hosted limesurvey system and it is not hiding the MyOther checkbox option on the hosted version.
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>

Do I need to use a different script?
The topic has been locked.
  • tpartner
  • tpartner's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
5 years 10 months ago - 5 years 10 months ago #168956 by tpartner
Replied by tpartner on topic MyOther not working in hosted version
We have no clue what "MyOther" is without some context and/or a small sample survey.

Cheers,
Tony Partner

Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
Last edit: 5 years 10 months ago by tpartner.
The topic has been locked.
  • holch
  • holch's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
5 years 10 months ago #168974 by holch
Replied by holch on topic MyOther not working in hosted version
And what version of LS is your hosted version?

I answer at the LimeSurvey forum in my spare time, I'm not a LimeSurvey GmbH employee.
No support via private message.

The topic has been locked.
  • tixeon
  • tixeon's Avatar Topic Author
  • Offline
  • Senior Member
  • Senior Member
More
5 years 10 months ago #168992 by tixeon
Replied by tixeon on topic MyOther not working in hosted version
Sorry for the lack of explanation. It is a solution from this forum that I use in almost every survey so I forgot it isn't common.
So it is a series of 2 questions: Q1 is a multiple response with other specify option and Q2 is an array that filters off Q1. The script adds a hidden box to Q1 that activates if text is entered in the other box. Then Q2 can see when other is an option that needs to be added to a row, and feeds through the text entered in the other box.

I have attached a survey file and am running the example here: asdfresearch.com.au/limesurvey/index.php/515495?lang=en

The hosted limesurvey is Version 3.7.2
The topic has been locked.
  • holch
  • holch's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
5 years 10 months ago #168993 by holch
Replied by holch on topic MyOther not working in hosted version
First of all, I would always use the same version for my local development environment as for the production environment, especially no major version changes. And you basically 2 major Limesurvey versions difference (2.7x and 3.x)!

The versions are significantly different.

I answer at the LimeSurvey forum in my spare time, I'm not a LimeSurvey GmbH employee.
No support via private message.

The topic has been locked.
  • tixeon
  • tixeon's Avatar Topic Author
  • Offline
  • Senior Member
  • Senior Member
More
5 years 10 months ago #169005 by tixeon
Replied by tixeon on topic MyOther not working in hosted version
Thank you for your reply. Rather than telling my life story about how I got into this rather urgent situation, I will instead re-frame the question:

Can you please advise how I get the new version 3.7.2 to do what I need (as described above and shown in the example link), which is get the array question (Q2) to pick up the other specify from the filter question (Q1) and feed it through as a row.
The topic has been locked.
  • tpartner
  • tpartner's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
5 years 10 months ago #169022 by tpartner
Replied by tpartner on topic MyOther not working in hosted version
This script will work in LS 3.x. It will hide the "myOther" check-box item and toggle it depending on the value in the "Other" text input.

Code:
<script type="text/javascript" charset="utf-8">  
    $(document).ready(function(){
 
    // Identify this question
    var thisQuestion = $('#question{QID}');
    var thisOther = $('input[type="checkbox"][id$="othercbox"]', thisQuestion);
    var thisOtherText = $('input[type="text"][id$="other"]', thisQuestion);
    var otherToggle = $('input[type="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 of "Other"
    function handleOther() {
      $(otherToggle).prop('checked', $(thisOther).prop('checked'));
      if($(otherToggle).is(':checked')) {
        $(otherToggle).nextAll('input:hidden:eq(0)').val('Y');
 
      }
      else{
        $(otherToggle).nextAll('input:hidden:eq(0)').val('');
      }
      checkconditions($(otherToggle).attr('value'), $(otherToggle).attr('name'), $(otherToggle).attr('type'))
 
     }              
 
        });
</script>

Sample survey attached:

File Attachment:

File Name: limesurvey...4951.lss
File Size:28 KB

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
5 years 10 months ago #169061 by tixeon
Replied by tixeon on topic MyOther not working in hosted version
Thank you!

I also just worked out that this functionality is now inbuilt in version 3 (thereby bypassing the need for a script):

Q1 add the other specify in the usual way ('other' option = yes)
Q2 add a row in the subquestions with the code 'other' with the text Other: {Q1_other} and the system will automatically add it if other is selected in Q1.
The topic has been locked.
  • Joffm
  • Joffm's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
5 years 10 months ago #169063 by Joffm
Replied by Joffm on topic MyOther not working in hosted version
Hi, tixeon,

exactly.

I just wanted to write it.
Now I see that you found out by yourself.

All the best
Joffm

Volunteers are not paid.
Not because they are worthless, but because they are priceless
The topic has been locked.

Lime-years ahead

Online-surveys for every purse and purpose