function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Lena RLena R 

How to set first radio button checked by default on aura:component load when using aura:iteration?

In my aura component, I iterate through an array of record types to render as radio buttons and would like to set the very first one to be selected by default. 
<aura:iteration items="{!v.recordTypes}" var="obj">
      <span class="slds-radio">
             <input type="radio" id="{!obj.Id}" name="options" />
              <label class="slds-radio__label" for="{!obj.Id}">
                   <span class="slds-radio--faux"></span>
                   <span class="slds-form-element__label">{!obj.Name}</span>
             </label>
     </span>
</aura:iteration>
Would anyone have a suggestion on how this can be achieved? Thank you in advance.
Ajay K DubediAjay K Dubedi
Hi Lena,

When you want to set first radio button checked by default so you only do one thing that when you create Radio button group like -
<ui:inputRadio aura:id="r0" name="radio" label="Prospecting" />
 <ui:inputRadio aura:id="r1" name="radio" label="Qualification" />
 <ui:inputRadio aura:id="r2" name="radio" label="Needs Analysis" />
 <ui:inputRadio aura:id="r3" name="radio" label="Closed Lost" />
So please make sure your first radio button ' value="true" ' like -
<ui:inputRadio aura:id="r0" name="radio" label="Prospecting" value="true" />
I hope it will help you.

Regards,
Ajay