Hiding scale points based on a condition | XM Community
Skip to main content
Solved

Hiding scale points based on a condition

  • June 25, 2020
  • 2 replies
  • 16 views

Forum|alt.badge.img+6

I have seen a few posts about this already but my rows are randomized so I cannot just go to a specific row and hide a scale point. I have a 0-10 satisfaction scale with a Not applicable. I have close to 20+ rows and I only need to enable the "Not applicable" to 4 of them. How can I do this if rows are randomized?

Best answer by SurajK

Add those text in span class with some class name (like in below code "op1, op2, op3..") where you need to show the radio buttons and do not add any span class for other options
And add the below codes as per your matrix layout,
// If you have applied border to matrix question
jQuery('tbody tr').find('td:last-child').each(function(){
jQuery(this).find('.q-radio').css('visibility','hidden')
})


jQuery('.op1').closest('tr').find('td:last-child').find('.q-radio').css('visibility','visible')
jQuery('.op2').closest('tr').find('td:last-child').find('.q-radio').css('visibility','visible')
jQuery('.op3').closest('tr').find('td:last-child').find('.q-radio').css('visibility','visible')
jQuery('.op4').closest('tr').find('td:last-child').find('.q-radio').css('visibility','visible')


// If you don't borders applied to matrix question
jQuery('tbody tr').find('td:last-child').each(function(){
jQuery(this).css('visibility','hidden')
})


jQuery('.op1').closest('tr').find('td:last-child').css('visibility','visible')
jQuery('.op2').closest('tr').find('td:last-child').css('visibility','visible')
jQuery('.op3').closest('tr').find('td:last-child').css('visibility','visible')
jQuery('.op4').closest('tr').find('td:last-child').css('visibility','visible')

2 replies

rondev
Level 6 ●●●●●●
Forum|alt.badge.img+22
  • Level 6 ●●●●●●
  • June 25, 2020

Instead of custom code, we can also use custom validation and add validation as for those other 16 rows "Not applicable is not selected"


SurajK
QPN Level 3 ●●●
Forum|alt.badge.img+4
  • QPN Level 3 ●●●
  • Answer
  • June 25, 2020

Add those text in span class with some class name (like in below code "op1, op2, op3..") where you need to show the radio buttons and do not add any span class for other options
And add the below codes as per your matrix layout,
// If you have applied border to matrix question
jQuery('tbody tr').find('td:last-child').each(function(){
jQuery(this).find('.q-radio').css('visibility','hidden')
})


jQuery('.op1').closest('tr').find('td:last-child').find('.q-radio').css('visibility','visible')
jQuery('.op2').closest('tr').find('td:last-child').find('.q-radio').css('visibility','visible')
jQuery('.op3').closest('tr').find('td:last-child').find('.q-radio').css('visibility','visible')
jQuery('.op4').closest('tr').find('td:last-child').find('.q-radio').css('visibility','visible')


// If you don't borders applied to matrix question
jQuery('tbody tr').find('td:last-child').each(function(){
jQuery(this).css('visibility','hidden')
})


jQuery('.op1').closest('tr').find('td:last-child').css('visibility','visible')
jQuery('.op2').closest('tr').find('td:last-child').css('visibility','visible')
jQuery('.op3').closest('tr').find('td:last-child').css('visibility','visible')
jQuery('.op4').closest('tr').find('td:last-child').css('visibility','visible')