New to the angular js need to know how to check radio button 'B' if Radio button 'A' is checked?
My code
<input type="radio" name ="employeeData.seatChange1" ng-model="employeeData.seatChange" value="yes" > A
<input type="radio" name ="employeeData.seatChange" ng-model="employeeData.seatChange" value="no" > B
<input type="radio" name ="employeeData.seatChange3" ng-model="employeeData.seatChange" value="no1" > C
see https://docs.angularjs.org/api/ng/input/input%5Bradio%5D
you'll want to have multiple radio buttons, each with it's own value to set some property to (although this is weird for a yes no you are better off with a checkbox, but if you had multiple values this is how radio buttons work)
<input type="radio" ng-model="employeeData.seatChange" ng-value="true" />A
<input type="radio" ng-model="employeeData.seatChange" ng-value="true" />B
when you have just one radio button, if it is not checked by default or you have no ng-value it will be undefined, but also having only one radio button, you could never unselect it.
Try this, Hope this Helps.
If you want to check both radio button ,rather than using radio button go for check box ,as I don't know why you are using radio button its better to use check box radio button.
If you want to use Radio button only then in the Don't use name as if name is used both radio button is grouped so one is checked then automatically other also unchecked which is default.So as VikrantMore says you can avoid name.
My advice as per requirement go for check box.
Related
i have few tabs and each tab has same radio button groups like this
see case#1 has radio buttons name="managerid" and with class="managerid
<label>
<input type="radio" name="managerid" class="managerid managerid_8" data-radio="iradio_square-grey" value="8">
Spam Dead
</label>
<label>
<input type="radio" name="managerid" class="managerid managerid_9" data-radio="iradio_square-grey" value="9">
Stewart Stephenson
</label>
these are dynamically generated tabs and radio buttons
now i want to set radio button checked in each tabs with the value
this is how im doing
$.each($("#tab_"+r.id).find(".managerid"),function(i,v){
if(v.value === r.managerid){
v.checked = true;
}
});
i know the id of the tab so i find() the managerid and set them checked if the value matches
the problem is that it sets radio checked on the last tab only
how do i set radios checked on each tab with different values
I would suggest you to assign different style class to radio button controls and that is a better possible way to select/deselect across multiple tabs
I need to select a radio input with name and value in jquery
In this example how you select element with name SiblingSex and value female
<form action="">
<input type="radio" name="SiblingSex" value="male">Male<br>
<input type="radio" name="SiblingSex" value="female">Female
<input type="radio" name="ParentSex" value="male">Male<br>
<input type="radio" name="ParentSex" value="female">Female
</form>
i need some thing like
$('input[name="SiblingSex"]' /*GENDER SELECTOR */)
You can add another attribute selector with this:
$('input[name="SiblingSex"][value="female"]').val();
the above line would give you values every time whether it is checked or not.
so if you only want to have the value when it is checked too then add :checked
$('input[name="SiblingSex"][value="female"]:checked').val();
Just have a look on the Demo on my JS Fiddle Code
Shows the two scenario:
1) when you want the value without selecting radio button.
2) when you want value after selecting radio button.
or may be the thing that you want is here::
JS Fiddle Demo
How to find the radio button Value in inner div while clicking on radio button
Hi i have a radio button i want to
find out the value of the radio button when clicking on that radio button in jQuery:
Please see here my problem http://jsfiddle.net/c857P/232/
jsFiddle Demo
You're missing the class="vvradiobtn" for your radio buttons
<input type="radio" name="VVradio" class="vvradiobtn" id="radio1" value="1">
<input type="radio" class="vvradiobtn" name="VVradio" id="radio2" value="2">
I see a few duplicate IDs in your DOM. I suggest to use unique IDs for your html elements.
I've used UniformJS before and am having an issue with radio buttons this time around. I have uniform initialized for only checkbox and radio, and I can check/uncheck checkboxes just fine. My radio buttons are stylized but not showing as clicked. I have no errors in the console, and I'm not sure what the issue could be. I copied the exact radio inputs from the working fiddle, with no luck. http://jsfiddle.net/Wp9kx/ When giving the attribute checked in the tag, it appears as clicked but will not unclick. It seems the click isn't getting pushed through the styling.Any ideas?
$("input[type=checkbox], input[type=radio]").uniform();
This will happen if your radio isn't inside a label.
This works:
<label>
<input type="radio" value="option1" />option 1
</label>
This doesn't:
<input type="radio" value="option1" />option 1
Here is the bug report.
I'm trying to get the value of a radio button on my JSP page with
document.getElementById('rButton').value
when I press a submit type button, but the line above only returns the value the radio button started with. It does not return the actual value of it. (true/false)
How can I check the actual value of the radio Button?
I'd appreciate some help. :)
Thanks.
Radio buttons (and checkboxes) have a checked property. Their value property/attribute is the value that is sent when they are checked.
try checked instead of value.
HTML:
<input type="radio" name="group2" value="Water"> Water<br>
<input type="radio" name="group2" value="Beer" checked> Beer<br>
<input type="radio" name="group2" value="Wine"> Wine
Javascript:
var radioBtns=document.getElementsByName("group2");
for(i=0;i<radioBtns.length; i++){
if(radioBtns[i].checked){
alert(radioBtns[i].value);
}
}