Ask Search:
thylak Productthylak Product 

how to create radio button using visualforce page in salesforce

how to create radio button using visualforce page in salesforce
Matthew LambMatthew Lamb
You can use the selectRadio component, here's a link from the Visualforce Developer's Guide.

http://www.salesforce.com/us/developer/docs/pages/index_Left.htm
Anumol AnoopAnumol Anoop
PFB an example

<!-- Page: -->
<apex:page controller="sampleCon">
<apex:form>
<apex:selectRadio value="{!country}">
<apex:selectOptions value="{!items}"/>
</apex:selectRadio><p/>
<apex:commandButton value="Test" action="{!test}" rerender="out" status="status"/>
</apex:form>
<apex:outputPanel id="out">
<apex:actionstatus id="status" startText="testing...">
<apex:facet name="stop">
<apex:outputPanel>
<p>You have selected:</p>
<apex:outputText value="{!country}"/>
</apex:outputPanel>
</apex:facet>
</apex:actionstatus>
</apex:outputPanel>
</apex:page>
/*** Controller ***/
public class sampleCon {
String country = null;
public PageReference test() {
return null;
}
public List<SelectOption> getItems() {
List<SelectOption> options = new List<SelectOption>();
options.add(new SelectOption('US','US'));
options.add(new SelectOption('CANADA','Canada'));
options.add(new SelectOption('MEXICO','Mexico')); return options;
}
public String getCountry() {
return country;
}
public void setCountry(String country) { this.country = country; }
}
bs881026 shbs881026 sh
In the above code, where are we binding the variable country with options ??

I mean i didnt understand, so please explain ..

Thanks,