How to set a default radio button with a value?

Mindi Torrey

General issue: I cannot set a default radio button in my radio groups unless I remove the value attribute from the inputs.

Specifics: Each input has a value that is needed as it is being used by angular in other places in the app. So, I need to know how to set an input to default checked while retaining the values on the inputs. It has the same behavior if I try to add checked with jQuery instead of in HTML.

I have looked at several related questions including here. The specific issue is I need to have values and be able to set one input to checked as a default. The first input is set to checked, but it does not actually work unless I remove the value from that input.

Here is the HTML:

<div class="radio">
   <label>
        <input type="radio" ng-model="optionsRadios" id="new" value="new" checked>
        New
   </label>

   <label>
        <input type="radio" ng-model="optionsRadios" id="used" value="used">
        Used
   </label>

   <label >
         <input type="radio" ng-model="optionsRadios" id="broken" value="broken">
         Broken
   </label>
</div>
MeTe-30

You have to use ng-checked="true" instead of checked

<input type="radio" ng-model="optionsRadios" id="new" value="new" ng-checked="true">

<!DOCTYPE html>
<html>
<script src="http://ajax.googleapis.com/ajax/libs/angularjs/1.4.8/angular.min.js"></script>
<body ng-app="">
<p>My cars:</p>
<input type="radio" ng-model="all" value="Volvo" ng-checked="true">Volvo<br>
<input type="radio" ng-model="all" value="Ford">Ford<br>
<input type="radio" ng-model="all" value="Mercedes">Mercedes
</body>
</html>

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

Set default value in radio button

From Dev

how to assign default value to the radio button in knockout

From Dev

how to set a radio button value in protractor

From Dev

Rails radio button: set default value based on model / database entry

From Dev

Set default dropdownlist value based on radio button change

From Dev

How to set value of a radio button inside a radio group android

From Dev

Default Radio button selected value

From Dev

Default Radio button selected value

From Dev

How to always set default checked radio button programmatically android?

From Dev

How can I set the default radio button using jquery

From Dev

How to always set default checked radio button programmatically android?

From Dev

How to set radio button checked default in other activities?

From Dev

Set the value of a nested radio button

From Java

How to select a radio button by default?

From Dev

How to check radio button with radio button value

From Dev

how to set and get the value of gender radio button in android studio?

From Dev

How to call directive on radio button to set value in Angular Js

From Dev

How to set radio button selected value using jquery

From Dev

Set default radio button in Android Studio

From Dev

Set Default Radio Button + Associated Div

From Dev

Selecting default value in radio button angularjs

From Dev

Get value of selected radio button which is saved in Firebase, and set it as default state in user profile

From Dev

How to default radio value in a loop?

From Dev

How to access the value of a radio button

From Dev

Set value (int) to checke radio button wpf

From Dev

Set input[text] value according to radio button

From Dev

How to customize default theme of radio button in android?

From Dev

How to have a default radio button checked in Ruby?

From Dev

android - how to reinitialize my radio button to default

Related Related

  1. 1

    Set default value in radio button

  2. 2

    how to assign default value to the radio button in knockout

  3. 3

    how to set a radio button value in protractor

  4. 4

    Rails radio button: set default value based on model / database entry

  5. 5

    Set default dropdownlist value based on radio button change

  6. 6

    How to set value of a radio button inside a radio group android

  7. 7

    Default Radio button selected value

  8. 8

    Default Radio button selected value

  9. 9

    How to always set default checked radio button programmatically android?

  10. 10

    How can I set the default radio button using jquery

  11. 11

    How to always set default checked radio button programmatically android?

  12. 12

    How to set radio button checked default in other activities?

  13. 13

    Set the value of a nested radio button

  14. 14

    How to select a radio button by default?

  15. 15

    How to check radio button with radio button value

  16. 16

    how to set and get the value of gender radio button in android studio?

  17. 17

    How to call directive on radio button to set value in Angular Js

  18. 18

    How to set radio button selected value using jquery

  19. 19

    Set default radio button in Android Studio

  20. 20

    Set Default Radio Button + Associated Div

  21. 21

    Selecting default value in radio button angularjs

  22. 22

    Get value of selected radio button which is saved in Firebase, and set it as default state in user profile

  23. 23

    How to default radio value in a loop?

  24. 24

    How to access the value of a radio button

  25. 25

    Set value (int) to checke radio button wpf

  26. 26

    Set input[text] value according to radio button

  27. 27

    How to customize default theme of radio button in android?

  28. 28

    How to have a default radio button checked in Ruby?

  29. 29

    android - how to reinitialize my radio button to default

HotTag

Archive