1. I have a multiple choice question (multiple selections allows). I want to perform a function whenever any one of the options is selected or unselected. Currently, I'm using javascript as below but it doesn't work (i think):
jQuery("#" + "QID1" + " .Selection ").on("click change", function(){
// some functio
});
2. I'd also like to check if a specific option is selected or unselected. I'm using javascript below but it seems also not work:
if(jQuery("#QR~QID1~1").prop("checked") == true)
{
// some function
};
if(jQuery("#QR~QID1~1").prop("checked") == false)
{
// some function
};
Eventually, I want to achieve some code that checks dynamically:
- if any option is just selected or unselected (or if any option is just 'clicked');
- if selected, which one;
- if unselected, which one.
and performs different actions when each option is selected and unselected like:
jQuery("#" + "QID1" + " .Selection ").on("click change", function(){
if(jQuery("#QR~QID1~1").prop("checked") == true)
{
// a
};
if(jQuery("#QR~QID1~".prop("checked") == false)
{
// b
};
if(jQuery("#QR~QID1~2").prop("checked") == true)
{
// c
};
if(jQuery("#QR~QID1~2").prop("checked") == false)
{
// d
};
});
Does anyone have any suggestions?
I think this is something related:https://www.qualtrics.com/community/discussion/5521/using-javascript-jquery-to-listen-for-checkboxes-being-checked-or-not, especially the "q-checked" thing. But I'm not sure how to incorporate it into my scenario specifically (really newbie to javascript).