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>
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.
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.
Help us to help you!
Provide your LS version and where it is installed (own server, uni/employer, SaaS hosting, etc.).
Always provide a LSS file (not LSQ or LSG).
Note: I answer at this forum in my spare time, I'm not a LimeSurvey GmbH employee.
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.
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>
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.