Welcome to the LimeSurvey Community Forum

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

"Exclusive option" in array

  • delarammahdaviii
  • delarammahdaviii's Avatar Topic Author
  • Offline
  • Senior Member
  • Senior Member
More
8 years 2 months ago #130390 by delarammahdaviii
"Exclusive option" in array was created by delarammahdaviii
hi
thanks for
i want use "Exclusive option" in array but for answer code , not for subquestion code
how can do it ?
The topic has been locked.
  • tpartner
  • tpartner's Avatar
  • Away
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
8 years 2 months ago #130395 by tpartner
Replied by tpartner on topic "Exclusive option" in array
Sorry, I don't understand the question. In an array, the answer options are already exclusive because they're radios.

Cheers,
Tony Partner

Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
The topic has been locked.
  • delarammahdaviii
  • delarammahdaviii's Avatar Topic Author
  • Offline
  • Senior Member
  • Senior Member
More
8 years 2 months ago - 8 years 2 months ago #130397 by delarammahdaviii
Replied by delarammahdaviii on topic "Exclusive option" in array
In an array (single choice per rows); i want choice answer in column , if one of the answer in D column is choose , another rows can't choose the answer D column .
Last edit: 8 years 2 months ago by delarammahdaviii.
The topic has been locked.
  • tpartner
  • tpartner's Avatar
  • Away
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
8 years 2 months ago #130399 by tpartner
Replied by tpartner on topic "Exclusive option" in array
Just for column D, or for all columns?

Cheers,
Tony Partner

Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
The topic has been locked.
  • delarammahdaviii
  • delarammahdaviii's Avatar Topic Author
  • Offline
  • Senior Member
  • Senior Member
More
8 years 2 months ago #130400 by delarammahdaviii
Replied by delarammahdaviii on topic "Exclusive option" in array
Just for column D
The topic has been locked.
  • tpartner
  • tpartner's Avatar
  • Away
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
8 years 2 months ago - 8 years 2 months ago #130407 by tpartner
Replied by tpartner on topic "Exclusive option" in array
In that case, adding this script to the question source should do the trick:

Code:
<script type="text/javascript" charset="utf-8">    
  $(document).ready(function() {  
 
    // Identify this question
    var thisQuestion = $('#question{QID}');
 
    // Assign column-specific classes
    $('table.subquestions-list tr', thisQuestion).each(function(i){
      $('> *', this).each(function(i){
        $(this).addClass('column-'+i+'');
        $(this).attr('data-column', i);
      });
    });
 
    // Define the column to have exclusive answers
    var exclusiveColumn = 4;
 
    // Listeners on the radios
    $('input.radio', thisQuestion).on('click', function(e) {
      var thisCell = $(this).closest('td');
      if($(thisCell).hasClass('column-'+exclusiveColumn)) {
        setTimeout(function () {
          $('.column-'+exclusiveColumn+' input.radio:not(:checked)', thisQuestion).prop('disabled', true);
        }, 100);
      }
      if($('.column-'+exclusiveColumn+' input.radio:checked', thisQuestion).length == 0) {
        $('.column-'+exclusiveColumn+' input.radio', thisQuestion).prop('disabled', false);
      }
    });
 
    // Initial radio state
    if($('.column-'+exclusiveColumn+' input.radio:checked', thisQuestion).length != 0) {
      $('.column-'+exclusiveColumn+' input.radio:not(:checked)', thisQuestion).prop('disabled', true);
    }
    });
</script>

Sample survey attached.

File Attachment:

File Name: limesurvey...47-2.lss
File Size:21 KB

Cheers,
Tony Partner

Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
Last edit: 8 years 2 months ago by tpartner.
The following user(s) said Thank You: delarammahdaviii
The topic has been locked.
  • DenisChenu
  • DenisChenu's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
8 years 2 months ago - 8 years 2 months ago #130445 by DenisChenu
Replied by DenisChenu on topic "Exclusive option" in array
ANd with EM (for PHP validation too (user deactivated javascript)

Question validation equation
Code:
countif("d",self.NAOK) <= 1

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.
Last edit: 8 years 2 months ago by DenisChenu.
The topic has been locked.
  • tpartner
  • tpartner's Avatar
  • Away
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
8 years 2 months ago - 8 years 2 months ago #130462 by tpartner
Replied by tpartner on topic "Exclusive option" in array
Yeah but I think the user experience with disabled radios is better. :)

Cheers,
Tony Partner

Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
Last edit: 8 years 2 months ago by tpartner.
The following user(s) said Thank You: delarammahdaviii
The topic has been locked.
  • Mazi
  • Mazi's Avatar
  • Offline
  • Official LimeSurvey Partner
  • Official LimeSurvey Partner
More
8 years 2 months ago #130469 by Mazi
Replied by Mazi on topic "Exclusive option" in array

DenisChenu wrote: ANd with EM (for PHP validation too (user deactivated javascript)

Question validation equation

Code:
countif("d",self.NAOK) <= 1

Denis, is that a custom validation for making sure that at the whole question option "d" is used only once?

Best regards/Beste Grüße,
Dr. Marcel Minke
Need Help? We offer professional Limesurvey support: survey-consulting.com
Contact: marcel.minke(at)survey-consulting.com
The topic has been locked.
  • DenisChenu
  • DenisChenu's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
8 years 2 months ago #130500 by DenisChenu
Replied by DenisChenu on topic "Exclusive option" in array

Mazi wrote: ....
Denis, is that a custom validation for making sure that at the whole question option "d" is used only once?

Yes

tpartner wrote: Yeah but I think the user experience with disabled radios is better. :)

Sure, but : need a PHP control :). Else a user can decativate JS (or js can be broken for some reason ;) ) and false value in DB.

I try always to
- Add specific desired behaviour in EM first
- Add some js for user experience
:)

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.
  • tpartner
  • tpartner's Avatar
  • Away
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
8 years 2 months ago #130506 by tpartner
Replied by tpartner on topic "Exclusive option" in array
Well, with JavaScript disabled LimeSurvey is almost useless anyway - there is no dynamic filtering or EM.

Cheers,
Tony Partner

Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
The topic has been locked.
  • delarammahdaviii
  • delarammahdaviii's Avatar Topic Author
  • Offline
  • Senior Member
  • Senior Member
More
8 years 2 months ago - 8 years 2 months ago #130530 by delarammahdaviii
Replied by delarammahdaviii on topic "Exclusive option" in array
hi
tnx all for reply:) :) :)


i so sorry this case is change
if one of the D column is select ; C and B else disable .user only can select from A or E
Last edit: 8 years 2 months ago by delarammahdaviii.
The topic has been locked.

Lime-years ahead

Online-surveys for every purse and purpose