Welcome to the LimeSurvey Community Forum

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

Generalize Java Script Workaround for removing comment text boxes

  • Alexitktwfo
  • Alexitktwfo's Avatar Topic Author
  • Offline
  • New Member
  • New Member
More
1 year 11 months ago #228175 by Alexitktwfo
Please help us help you and fill where relevant:
Your LimeSurvey version: Version 3.17.4+190529
Own server or LimeSurvey hosting: own
Survey theme/template: own based on fruity
==================
Hello,

I removed the comment boxes/text boxes from a multiple choice question with comment boxes with the following code below.
When creating a new survey that is a copy of the survey I would like the java script solution to still function without having to manually enter the survey id/question group id and question id into the js workaround in the question.

Can I generalise the solution by using #question{QID} somehow instead of id="answer37771X218X6777othercomment"

All the best and thank you.
Code:
<script type="text/javascript" charset="utf-8">
 
   $(document).ready(function() {
 
       $('input[id="answer37771X218X6777othercomment"]').remove();
       $('input[id="answer37771X218X67771comment"]').remove();
 
   });
 
</script>
 

Please Log in to join the conversation.

  • Joffm
  • Joffm's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
1 year 11 months ago #228183 by Joffm
Hi,
I do not know how old this code is

Here is another solution
Code:
<script type="text/javascript" charset="utf-8">
$(document).ready(function() {
  var thisQuestion = $('#question{QID}');
  // Remove some text inputs
  $('.checkbox-text-item:eq(0) .comment-item', thisQuestion).remove();
  $('.checkbox-text-item:eq(1) .comment-item', thisQuestion).remove();
  $('.checkbox-text-item:eq(2) .comment-item', thisQuestion).remove();
  $('.checkbox-text-item:eq(4) .comment-item', thisQuestion).remove();
  $('.checkbox-text-item:eq(6) .comment-item', thisQuestion).remove();
});
</script>

On the other side you may use {SGQ}

Joffm

Volunteers are not paid.
Not because they are worthless, but because they are priceless
The following user(s) said Thank You: Alexitktwfo

Please Log in to join the conversation.

  • Alexitktwfo
  • Alexitktwfo's Avatar Topic Author
  • Offline
  • New Member
  • New Member
More
1 year 11 months ago - 1 year 11 months ago #228196 by Alexitktwfo
Thank you. That´s perfect!
Last edit: 1 year 11 months ago by Alexitktwfo.

Please Log in to join the conversation.

Lime-years ahead

Online-surveys for every purse and purpose