Welcome to the LimeSurvey Community Forum

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

Additional Checkbox below short free-text

  • RitaShen
  • RitaShen's Avatar Topic Author
  • Offline
  • Premium Member
  • Premium Member
More
4 years 6 months ago #189178 by RitaShen
can we combining short free-text and radio buttons in an array?
but I don't want to use the plugin.


e.g. the question is ask the name about some people
and if the don't know the answer, they can choose directly
The topic has been locked.
  • DenisChenu
  • DenisChenu's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
4 years 6 months ago #189180 by DenisChenu
Replied by DenisChenu on topic Additional Checkbox below short free-text
Without plugin : need 2 question (and not a radio , because you can't uncheck radio).

Assistance on LimeSurvey forum and LimeSurvey core development are on my free time.
I'm not a LimeSurvey GmbH member, professional service on demand , plugin development .
I don't answer to private message.
The topic has been locked.
More
4 years 6 months ago #189182 by orvil
Replied by orvil on topic Additional Checkbox below short free-text
+1
This is an excellent idea for survey taking practice!

Meanwhile: I ask participants to edit an "x" if they don't know
The reason: if participants have to change from mouse/pad to keyboard it's more likely that they will do an editing.
If they don't have to change, there is a small probability that some will remain in the behaviour of mouse-using and click to "I don't know", even if they do know - because it's a little more in the flow and convenient.
What is your experience?

Best regards/Beste Grüße,
O. Villani
The topic has been locked.
  • Joffm
  • Joffm's Avatar
  • Away
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
4 years 6 months ago - 4 years 6 months ago #189280 by Joffm
Replied by Joffm on topic Additional Checkbox below short free-text
Hi, Rita,

your example looks exactly like one I showed some (long) time ago.
There is a javascript workaround.
I hope I find it.

Joffm

Found it.
And saw that this was an answer to you
Well, you have this already, but it is for 2.50/2.73.
And it doesn't work in 3.x.?

Volunteers are not paid.
Not because they are worthless, but because they are priceless
Last edit: 4 years 6 months ago by Joffm.
The topic has been locked.
  • Joffm
  • Joffm's Avatar
  • Away
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
4 years 5 months ago #189283 by Joffm
Replied by Joffm on topic Additional Checkbox below short free-text
Hi, Rita,
I took the "old" script and changed one line
Code:
<script type="text/javascript" charset="utf-8">
  $(document).ready(function(){  
 
    // Identify this question
    var qID = {QID};
    var thisQuestion = $('#question'+qID);
 
    // Add some classes
    $(thisQuestion).addClass('with-exclusive-items');
    $('td.answer-item', thisQuestion).addClass('non-exclusive-item');
 
    // Loop through the last-column cells
    $('td.answer-item:last-child', thisQuestion).each(function(i) {
      varThisID = $('input[type="text"]', this).attr('id');
 
      // Add a class
      $(this).removeClass('non-exclusive-item').addClass('exclusive-item');
 
      // Hide the text input
      $('td.answer-item:last-child input[type="text"]', thisQuestion).hide();
 
      // Insert checkboxes
      $(this).append('<div class="checkbox">\
                <input class="checkbox" name="" id="'+varThisID+'_cbox" value="N/A" type="checkbox">\
                <label for="'+varThisID+'_cbox" class="answertext inserted-label"></label>\
              </div>'); 
    });
 
    // Listener on the checkboxes
    $('.exclusive-item input[type="checkbox"]', thisQuestion).on('change', function(e) {
      var thisRow = $(this).closest('tr.subquestion-list');
      var thisCell = $(this).closest('td.answer-item');
      if($(this).is(':checked')) {
        $('input[type="text"]', thisCell).val('1');
        $('.non-exclusive-item input[type="text"]', thisRow).val('');
      }
      else {
        $('input[type="text"]', thisCell).val('');
      }
 
      // Fire Expression Manager
      $('input[type="text"]', thisRow).each(function(i) {
        $(this).trigger('keyup');
      });
    });
 
    // Listener on the text inputs
    $('.non-exclusive-item input[type="text"]', thisQuestion).on('keyup change', function(e) {
      var thisRow = $(this).closest('tr.subquestion-list');
      if($.trim($(this).val()) != '') {
        $('.exclusive-item input[type="checkbox"]', thisRow).prop('checked',false);
        $('.exclusive-item input[type="text"]', thisRow).val('');
      }
 
      // Fire Expression Manager
      $('.exclusive-item input[type="text"]', thisRow).trigger('keyup');
    });
 
    // Insert some styles (these could be in template.css)
    // For the LS 2.67 default template
    var newStyles = '.with-exclusive-items thead th.answertext {\
              text-align: center;\
            }\
            .with-exclusive-items .exclusive-item {\
              text-align: center;\
              vertical-align: middle;\
              cursor: pointer;\
            }\
            .with-exclusive-items .checkbox {\
              padding-left: 50%;\
            }\
            .with-exclusive-items .inserted-label {\
              width: 24px;\
              min-height: 24px;\
              padding: 0;\
            }\
            .with-exclusive-items .inserted-label::before {\
              margin: 4px 0 0 4px;\
            }\
            .with-exclusive-items .inserted-label::after {\
              margin: 4px 0 0 4px;\
            }';  
    $('head').append('<style type="text/css">'+newStyles+'</style>');  
  });  
 
</script>

Here I changed the padding to 50%
.with-exclusive-items .checkbox {\
padding-left: 50%;\


Furthermore I added some css to set the width of the columns.
Code:
<style type="text/css">
col:first-child {width:30% !important}
col:nth-child(2)  {width:60% !important}
col:last-child {width:10% !important}
</style>



You said you don't want to use the plugin.
Do you talk about "checkboxForText"?
Why?



Joffm

Volunteers are not paid.
Not because they are worthless, but because they are priceless
The topic has been locked.
  • RitaShen
  • RitaShen's Avatar Topic Author
  • Offline
  • Premium Member
  • Premium Member
More
4 years 5 months ago #189284 by RitaShen
Replied by RitaShen on topic Additional Checkbox below short free-text
Because I use the LimeSurvey Professional , which means I don't have my own server.
so I cannot use the plugins
The topic has been locked.
  • RitaShen
  • RitaShen's Avatar Topic Author
  • Offline
  • Premium Member
  • Premium Member
More
4 years 5 months ago #189285 by RitaShen
Replied by RitaShen on topic Additional Checkbox below short free-text
my survey version is 3.18.0
The topic has been locked.
  • Joffm
  • Joffm's Avatar
  • Away
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
4 years 5 months ago #189289 by Joffm
Replied by Joffm on topic Additional Checkbox below short free-text
Yes, that's a reason not to use the plugin.

But you already showed the "array" solution.
That's fine as well.

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