+ Start a Discussion

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" />


 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; 

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)

Anjith Kumar.