A radio button is an element of interaction. This element is called an option button. It is also known as a control or widget in a graphical user interface. Examples of this are a button and a scroll bar. These are software components that are used by the computer to interact with a human to read or edit information about the program.

One of its functions is to allow the user to pick one limited set of correlative exclusive options. It appears as a list of circular holes displayed on the screen. Selecting one from the group of radio buttons automatically de-selects other buttons because only one option can be selected. Once a button is selected, a dot inside the hole will appear.

To display a radio button in web forms, the HTML element used is <input type=”radio”>.

You could set first your radio buttons which are to be checked by default.  To choose a radio button default, you can use the checked attribute. It can be done by adding “checked” right inside of an input element. For instance:  <input type=”radio” name=”test-name” checked>.

Using “checked” is the valid way to pre-check a radio button.

In some cases, “checked” don’t usually work most especially if you are using AngularJS. The other way to set radio buttons default is by setting the ‘ng-checked’ flag to:

“true” eg: <input id=”d_man” value=”M” ng-disabled=”some Value” type=”radio” ng-checked=”true”>Man

When mValue is declared in the controller which is linked to the radio buttons, a radio button will be preselected when you assign the $scope variable linked to the specific group to the intended input’s value: $scope.mValue=”second”

It enables the “second” radio button to get chosen upon loading your page. For versions, 2.x and up, it is better to use “ng-checked” attribute.

Setting radio button default would seem complicated. It’s really important to follow a certain format depending on a version you are currently using. It should be compatible to work 100%. If this still doesn’t work, then you can check references online. There are forums and discussions about this matter. Just don’t hesitate to ask.

Leave a Reply

Your email address will not be published. Required fields are marked *