How to enable the radio button when the checkbox is tick | XM Community

How to enable the radio button when the checkbox is tick

  • 22 November 2022
  • 4 replies
  • 295 views

Badge +2

Hi Community
I'm trying to working with 2 disabled radio button and enable the two radio button (Yes , No) when the checkbox is being tick,
image.png


4 replies

Userlevel 6
Badge +27

Use click event on checkbox element to enable/ disable the last column.

Badge +2

Hi Shashi, I tried this code however it does disable the radio button but never enable when the i check the checkbox

Qualtrics.SurveyEngine.addOnload(function()
{
//1st rows only
jQuery('input[type="checkbox"]').on("click",function(){
if(jQuery( "[id='QR~QID129#1~1~1']" ).prop('checked')== true)
 {
jQuery('[id="QR~QID129#2~1~1"]').prop("disabled",false);
jQuery('[id="QR~QID129#2~1~2"]').prop("disabled",false);  
 }
else { 
  jQuery('[id="QR~QID129#2~1~1"]').prop("checked",true);
jQuery('[id="QR~QID129#2~1~2"]').prop("checked",true);
}
  });
});
Qualtrics.SurveyEngine.addOnReady(function()
{
//1st rows only
jQuery('input[type="checkbox"]').on("click",function(){
if(jQuery( "[id='QR~QID129#1~1~1']" ).prop('checked')== true)
 {  
jQuery('[id="QR~QID129#2~1~1"]').prop("disabled",false).val('');
jQuery('[id="QR~QID129#2~1~2"]').prop("disabled",false).val('');  
 }
else { 
  jQuery('[id="QR~QID129#2~1~1"]').prop("checked",true);
jQuery('[id="QR~QID129#2~1~2"]').prop("checked",true);
}
  });
});

Userlevel 7
Badge +36

https://community.qualtrics.com/XMcommunity/discussion/23095/how-to-enable-the-radio-button-when-the-checkbox-is-tickHey ricsdpl
I made a slight adjustment to enable/disable and uncheck the values. Hope this is what is required. It's just for first row.
Qualtrics.SurveyEngine.addOnload(function()
{
/*Place your JavaScript here to run when the page loads*/
jQuery('[id="QR~QID129#2~1~1"]').prop("disabled",true);


jQuery('[id="QR~QID129#2~1~2"]').prop("disabled",true);

});
Qualtrics.SurveyEngine.addOnReady(function()


{


//1st rows only


jQuery('input[type="checkbox"]').on("click",function(){


if(jQuery( "[id='QR~QID129#1~1~1']" ).prop('checked')== true)


 {


jQuery('[id="QR~QID129#2~1~1"]').prop("disabled",false);


jQuery('[id="QR~QID129#2~1~2"]').prop("disabled",false);  


 }


else { 


jQuery('td.c7>label')[0].className='q-radio';
jQuery('td.c8>label')[0].className='q-radio';
jQuery('[id="QR~QID129#2~1~1"]').prop("disabled",true);


jQuery('[id="QR~QID129#2~1~2"]').prop("disabled",true);
}


  });


});


Hope it helps!

Badge +2

Thank you Deepak!

Leave a Reply