I have two columns in a side-by-side question. Column 1 has options 1-4, the 4th of which is 'N/A'. Is there a simple way I could disable the second column if 'N/A' is selected in column 1?
Right now I have
jQuery("#"+this.questionId+" input[type='radio']").on('click',function(){
if(jQuery(this).val()==4){
jQuery("[id='QR~QID106#2~1']").prop("disabled", true);
jQuery("[id='QR~QID106#2~2']").prop("disabled", true);
jQuery("[id='QR~QID106#2~3']").prop("disabled", true);
}
});
but because I have three rows, the above disables the second column entirely if option 4 is selected for ANY of the three rows. How can I edit this so it only disables the row where N/A is selected in the first column?
Solved
How can I disable a dropdown list in a second column if N/A is selected in column 1?
Best answer by TomG
Don't use ids. Find the second column element relative to the first. For example, if the second column is a text input:
var col1 = jQuery(this);
if(col1.val()==4) col1.closest("tr").find(".InputText").prop("disabled",true);
Enter your E-mail address. We'll send you an e-mail with instructions to reset your password.
