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
ajithMajithM 

How to Pre Select a radio button?

How to Preselect a radio button? I am saving the selected value to Opportunity.PaymentType__c text field.. On page load I want to preselect the radio button which was selected before. 


Here is the code: 

apex:pageBlockSection >
               <apex:actionRegion >
                 <apex:selectRadio value="{!currentOpportunity.PaymentType__c}" id="paymentType" required="true" style="required">
                           <apex:selectOptions value="{!PaymentMethods}" id="paymentMethods" />
                            <apex:actionSupport event="onclick" reRender="paymentDetails" status="status" immediate="false" />

                       </apex:selectRadio>
                </apex:actionRegion>
             </apex:pageBlockSection>

 public List<SelectOption> getPaymentMethods(){
        
        List<SelectOption> options = new List<SelectOption>();
        options.add(new SelectOption('VISA','VISA'));
        options.add(new SelectOption('MASTER','MASTER'));
        options.add(new SelectOption('ACH','ACH'));

        return options; 

    }
    
AnjithKumarAnjithKumar
Hello Ajith,

You have use same key what your PaymentType__c field is having in select option.

For more help: https://developer.salesforce.com/forums/?id=906F000000096VZIAY (https://developer.salesforce.com/forums/?id=906F000000096VZIAY" target="_blank)

Thanks,
Anjith Kumar.