Reputation: 1190
I have the following code to check if the radio buttons are checked with value true to show a row named FollowUp
.
showHideFollowup: function (e) {
e.preventDefault();
if ($("input[type='radio'][name='" + e.target.name + "']:checked").val() == "true") {
$(".questionRow" + e.target.name + "Followup").show();
}
else {
$(".questionRow" + e.target.name + "Followup").hide();
$(".questionRow" + e.target.name + "Followup input").val(null);
$(".questionRow" + e.target.name + "Followup textarea").val(null);
$(".questionRow" + e.target.name + "Followup input[type='radio']").prop("checked", null);
}
},
I would like to show FollowUp section for all the radio buttons value true except one. After modifying it as follows is not showing followUp section for any radio button because it is checking for rbThisIsNotWorking to be false. How can I achieve what I am looking for?
if (($("input[type='radio'][name='" + e.target.name + "']:checked").val() == "true" && $('input:radio[name="#rbThisIsNotWorking"]:checked').val() == "false")) {
$(".questionRow" + e.target.name + "Followup").show();
}
Upvotes: 1
Views: 870
Reputation: 388316
I think what you are after ism to check whether the rbThisIsNotWorking
element is not checked
if ($("input:not(#rbThisIsNotWorking)[type='radio'][name='" + e.target.name + "']").is(':checked')) {
$(".questionRow" + e.target.name + "Followup").show();
} else {
$(".questionRow" + e.target.name + "Followup").hide();
$(".questionRow" + e.target.name + "Followup input").val(null);
$(".questionRow" + e.target.name + "Followup textarea").val(null);
$(".questionRow" + e.target.name + "Followup input[type='radio']").prop("checked", null);
}
Upvotes: 1