Welcome to the LimeSurvey Community Forum

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

Different Maximum Value in Array (Numbers) for each column

  • mforster
  • mforster's Avatar Topic Author
  • Offline
  • New Member
  • New Member
More
6 years 10 months ago #155003 by mforster
Hello everybody,


I am actually building a Array with 3 column & 2 lines. I would like to put different Maximum Value on each column.

For example :
Answer Column 1 :1 => 10 ;
Answer Column 2 : 1=> 5 ;
Answer Column 3 : 1 => 8;

It is possible ? If not, is it possible to hide the unwanted answer ?

Thanks for your help
The topic has been locked.
  • tpartner
  • tpartner's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
6 years 10 months ago #155013 by tpartner
You can do that with a little JavaScript.

Assuming, for the sake of this example, x-scale question codes "X001", "X002" and "X003".

Set up your survey to use JavaScript and place the following script in the source of the question:

Code:
<script type="text/javascript" charset="utf-8">
  $(document).ready(function(){  
 
    // Column 2, remove all options greater than 5 
    $('#question{QID} select[id$="_X002"] option').filter(function( index ) {
      return $(this).val() > 5;
    }).remove();  
 
    // Column 3, remove all options greater than 8 
    $('#question{QID} select[id$="_X003"] option').filter(function( index ) {
      return $(this).val() > 8;
    }).remove();        
 
 
  });
</script>

Sample survey attached:

File Attachment:

File Name: limesurvey...18-2.lss
File Size:17 KB

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: mforster
The topic has been locked.
  • mforster
  • mforster's Avatar Topic Author
  • Offline
  • New Member
  • New Member
More
6 years 10 months ago #155014 by mforster
Perfect. Thank you for the quick answer !
The topic has been locked.

Lime-years ahead

Online-surveys for every purse and purpose