Reputation: 31
I was wondering if there is a way where i have i 2 groups of radio button eg
group 1
<input type="radio" name="things" value="car" /> car
<input type="radio" name="things" value="car" />pen
<input type="radio" name="things" value="car" />TV
group2
<input type="radio" name="things" value="exam" /> exam
<input type="radio" name="things" value="journey" />journey
the question is if i select radio button from group2 Eg exam it should deactivate radio butons car And Tv from group1 and allow only pen radio button active
Upvotes: 1
Views: 1018
Reputation: 187110
Modifying your HTML a bit
<div id="grp1">
<input type="radio" name="things" value="car" /> car
<input type="radio" name="things" value="pen" />pen
<input type="radio" name="things" value="tv" />TV
</div>
<div id="grp2">
<input type="radio" name="things" value="exam" /> exam
<input type="radio" name="things" value="journey" />journey
</div>
$(function(){
$("#grp2 input:radio[name='things']").change(function(){
$("#grp1 input:radio[name='things'][value!='pen']").attr("disabled", true);
});
});
See a working demo
Upvotes: 2
Reputation:
$("input[value="exam"]").click(function() {
$("input[value=\"car\"").attr("disabled", "disabled");
});
This should disable the "car" input when the exam radio button is clicked.
Upvotes: 0