Welcome to the LimeSurvey Community Forum

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

Automatically check box if people provide a comment in a 'mc question'

  • psk123
  • psk123's Avatar Topic Author
  • Offline
  • New Member
  • New Member
More
7 years 3 weeks ago #152014 by psk123
Dear Limesurvey users,

Using the question type 'mc question with comments', I would like that Limesurvey automatically ticks / checks the box if respondents leave a comment.

* Example *
Q1: What is your favorite animal?
[] Dog
[] Cat
[] Other, specify ____

=======

When respondents start writing something after specify (eg., 'bird'), the box before 'Other', needs to be ticked automatically.

======

[x] Other, specify bird

======

Thank you!
The topic has been locked.
  • holch
  • holch's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
7 years 3 weeks ago #152018 by holch
If your case is just to add ONE other, as you describe, I would rather use "multiple choice" and activate the other option, because there the behaviour is how you wish. As soon as you write something in the other text box, the checkbox is automatically ticked by Limesurvey.
Of course this version does not work if you need more than one comment box. But for your example given, this is actually the correct question type and setting.

For the multipe choice with comments you need to first tick the checkbox and then write the comment, otherwise you will receive an error message. There you would have to create a workaround with Javascript or something.

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.
  • psk123
  • psk123's Avatar Topic Author
  • Offline
  • New Member
  • New Member
More
7 years 2 weeks ago #152118 by psk123
Dear Holch,


Thank you for your answer.


No, respondents may select multiple answers. Thus, a specific respondent may select:

=========
* Example *
Q1: What is your favorite animal?
[X] Dog
[] Cat
[X] Other, specify bird
[X] Other, specify snake
=========

Can you give a Javascript hint?

Thank you.
The topic has been locked.
  • holch
  • holch's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
7 years 2 weeks ago #152137 by holch

Can you give a Javascript hint?


No, not a Javascript expert.

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.
  • psk123
  • psk123's Avatar Topic Author
  • Offline
  • New Member
  • New Member
More
7 years 2 weeks ago #152139 by psk123
Hi all,

Thanks to my ICT-buddy

======
Code:
<script type="text/javascript" charset="utf-8">
 
    $(document).ready(function() {
 
    var qID = 769;
     var questionInput = '#question'+qID+' input[type="text"]';
 
       $('.comment-container input[type="text"]').keypress(function() {
         var name = $(this).attr('name');
         var selectName = name.replace('comment', '') ;
         var selectName2 = '#answer' + selectName;
         var el = $.find(selectName2);
         $(el).prop('checked', true);
      });
    $(questionInput).autocomplete({
      minLength: 2,
      source: ["Test1","Test2","Test3"]
    });
 
 
 
 
  });
 
</script>
The topic has been locked.

Lime-years ahead

Online-surveys for every purse and purpose