Welcome to the LimeSurvey Community Forum

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

First Option In Array (Numbers) (Checkboxes) Row Excludes All Others

  • Georeorinc_191233
  • Georeorinc_191233's Avatar Topic Author
  • Offline
  • Banned
  • Banned
More
4 years 7 months ago #188133 by Georeorinc_191233
Hi,

Can I make the first column on my array an exclusive option? It's the same as Last Option In Array (Numbers) (Checkboxes) Row Excludes All Others but I want the first column instead of last.

Thanks
The topic has been locked.
  • Joffm
  • Joffm's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
4 years 7 months ago #188144 by Joffm
Hi,
your link refers to solutions of three different versions of LimeSurvey.
2.06, 2.50/2.73 and 3.x

If you work with version 3.x you see that in the script there is a part "$('.normal-item:last'"

Did you try to change it to "$('.normal-item:first'"?

Joffm

Volunteers are not paid.
Not because they are worthless, but because they are priceless
The following user(s) said Thank You: tpartner
The topic has been locked.
  • tpartner
  • tpartner's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
4 years 7 months ago #188149 by tpartner
Why do I bother commenting code if no one reads it?

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: DenisChenu
The topic has been locked.
  • DenisChenu
  • DenisChenu's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
4 years 7 months ago #188171 by DenisChenu

tpartner wrote: Why do I bother commenting code if no one reads it?

For the user who read it :)

Thanks a lot for commenting your code :)

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.
  • Georeorinc_191233
  • Georeorinc_191233's Avatar Topic Author
  • Offline
  • Banned
  • Banned
More
4 years 7 months ago #188202 by Georeorinc_191233
Thank you! This is perfect.
The topic has been locked.
  • Georeorinc_191233
  • Georeorinc_191233's Avatar Topic Author
  • Offline
  • Banned
  • Banned
More
4 years 7 months ago #188203 by Georeorinc_191233
Hi guys,

One more thing:

Right now, when the user chose "no change desired" all other options are disabled. But I also want to set it up that when the "yes, do more often" was clicked they cannot select "yes, do less often" and vice versa. Is this possible?

Thanks a lot!
The topic has been locked.
  • tpartner
  • tpartner's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
4 years 7 months ago #188209 by tpartner
Can you attach a small sample survey (.lss file) containing only that question and your script?

Cheers,
Tony Partner

Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
The topic has been locked.
  • Georeorinc_191233
  • Georeorinc_191233's Avatar Topic Author
  • Offline
  • Banned
  • Banned
More
4 years 7 months ago #188210 by Georeorinc_191233
Hi Tony,

Attached is the LSS file.
Attachments:
The topic has been locked.
  • tpartner
  • tpartner's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
4 years 7 months ago #188221 by tpartner
This will render the column-2 and column-3 check-boxes exclusive of each other:

Code:
<script type="text/javascript" charset="utf-8">
 
  $(document).on('ready pjax:scriptcomplete',function(){
 
    // Listener on the column-2/column-3 checkboxes
    $('#question{QID} td.question-item:nth-child(3) input[type="checkbox"], #question{QID} td.question-item:nth-child(4) input[type="checkbox"]').on('change', function(e) {
 
      if($(this).is(':checked')) {
 
        var targetIndex = 3;
        if($(this).closest('td').is(':nth-child(3)')) {
          targetIndex = 4;
        }
        var thisRow = $(this).closest('tr');
 
        // Uncheck the other checkbox
        $('td.question-item:nth-child('+targetIndex+') input[type="checkbox"]', thisRow).prop('checked', false).trigger('change');
      }
    });
  });
</script>

Here is your sample survey with that addition:

File Attachment:

File Name: limesurvey...7677.lss
File Size:24 KB

Cheers,
Tony Partner

Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
The topic has been locked.
  • Georeorinc_191233
  • Georeorinc_191233's Avatar Topic Author
  • Offline
  • Banned
  • Banned
More
4 years 7 months ago #188227 by Georeorinc_191233
Perfect! Thank you Tony!
The topic has been locked.

Lime-years ahead

Online-surveys for every purse and purpose