Welcome to the LimeSurvey Community Forum

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

How can I delete a specific option in a matrix

  • Episteme Investigación e Intervención Social
  • Episteme Investigación e Intervención Social's Avatar Topic Author
  • Offline
  • Junior Member
  • Junior Member
More
6 months 1 week ago #251245 by Episteme Investigación e Intervención Social
How can I delete a specific option in a matrix was created by Episteme Investigación e Intervención Social
Please help us help you and fill where relevant:
Your LimeSurvey version: [see right hand bottom of your LimeSurvey admin screen]
Own server or LimeSurvey hosting:
Survey theme/template:
==================
Hi,
I have a matrix with 3 rows (A, B, C) and 3 columns (1,2,3) and I want to delete an option in a matrix (A3). I tried to do it with a code similar to this one:
<script type="text/javascript" charset="utf-8">
 
  $(document).ready(function() {
 
    // Remove row 1, answer "A3"
    $('#question{QID} tr.answers-list:eq(0) input:radio[value="A3"]').nextAll('label').remove();
    $('#question{QID} tr.answers-list:eq(0) input:radio[value="A3"]').remove();
 
  });  
</script>

but this code it's from an old post and now it's not working in Lime writted like this in "script".

Does anyone have a better solution? Thank you very much!
 

Please Log in to join the conversation.

  • tpartner
  • tpartner's Avatar
  • Online
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
6 months 1 week ago #251246 by tpartner
Replied by tpartner on topic How can I delete a specific option in a matrix
We cannot help if you don't answer the questions about your LimeSurvey version etc.

Cheers,
Tony Partner

Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.

Please Log in to join the conversation.

  • Episteme Investigación e Intervención Social
  • Episteme Investigación e Intervención Social's Avatar Topic Author
  • Offline
  • Junior Member
  • Junior Member
More
6 months 1 week ago #251247 by Episteme Investigación e Intervención Social
Replied by Episteme Investigación e Intervención Social on topic How can I delete a specific option in a matrix
I have the Version 5.6.38
theme: Fruity Theme ( fruity)

Please Log in to join the conversation.

  • Joffm
  • Joffm's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
6 months 1 week ago - 6 months 1 week ago #251250 by Joffm
Use this, adapt it..
You see, both row and column are addressed by ":eq(x)"
Code:
<script type="text/javascript" charset="utf-8">
     $(document).ready(function() {
    // Remove in row 1
    $('#question{QID} tr[id^="javatbd"]:eq(0) .radio-item:eq(0) *').remove();
    $('#question{QID} tr[id^="javatbd"]:eq(0) .radio-item:eq(1) *').remove();
    // Remove in row 6
    $('#question{QID} tr[id^="javatbd"]:eq(5) .radio-item:eq(3) *').remove();
    $('#question{QID} tr[id^="javatbd"]:eq(5) .radio-item:eq(4) *').remove();
    // Remove in row 7
    $('#question{QID} tr[id^="javatbd"]:eq(6) .radio-item:eq(0) *').remove();
    $('#question{QID} tr[id^="javatbd"]:eq(6) .radio-item:eq(1) *').remove();
    $('#question{QID} tr[id^="javatbd"]:eq(6) .radio-item:eq(3) *').remove();
    $('#question{QID} tr[id^="javatbd"]:eq(6) .radio-item:eq(4) *').remove();
  });
</script>

 

Volunteers are not paid.
Not because they are worthless, but because they are priceless
Last edit: 6 months 1 week ago by Joffm.

Please Log in to join the conversation.

  • Episteme Investigación e Intervención Social
  • Episteme Investigación e Intervención Social's Avatar Topic Author
  • Offline
  • Junior Member
  • Junior Member
More
6 months 1 week ago #251253 by Episteme Investigación e Intervención Social
Replied by Episteme Investigación e Intervención Social on topic How can I delete a specific option in a matrix
Im trying the same with your cade and nothing happens:

I wrote this in "script":

$(document).ready(function() {
// Remove in row 1, col 3
$('#question{QID} tr[id^="javatbd"]:eq(a) .radio-item:eq(3) *').remove();
});

I attach the .lss
 

File Attachment:

File Name: DeleteOpti...trix.lss
File Size:24 KB

Please Log in to join the conversation.

  • Joffm
  • Joffm's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
6 months 1 week ago #251255 by Joffm
eq(a) ????
What is this?
You saw that all values x of eq(x) are numerical and how they refer to row resp.  column.
It always starts with "0" for the first row/col.

Joffm 
 

Volunteers are not paid.
Not because they are worthless, but because they are priceless

Please Log in to join the conversation.

  • tpartner
  • tpartner's Avatar
  • Online
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
6 months 1 week ago #251262 by tpartner
Replied by tpartner on topic How can I delete a specific option in a matrix

Cheers,
Tony Partner

Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.

Please Log in to join the conversation.

Lime-years ahead

Online-surveys for every purse and purpose