How to create checkboxes in Visualforce page in Salesforce?

Sample Code:

<apex:page >
<apex:form >
    <apex:pageBlock >
        <apex:pageBlockSection >
            <apex:pageBlockSectionItem >Name<apex:inputText /></apex:pageBlockSectionItem>
            <apex:pageBlockSectionItem >Age:
                <apex:selectRadio >
                    <apex:selectOption itemLabel="Male" itemValue="m"/>
                    <apex:selectOption itemLabel="Female" itemValue="f"/>           
                </apex:selectRadio>     
            </apex:pageBlockSectionItem>
            <apex:pageBlockSectionItem >Skills:
                <apex:selectcheckboxes layout="pageDirection">
                    <apex:selectOption itemLabel="C" itemValue="f"/>
                    <apex:selectOption itemLabel="C++" itemValue="cpp"/>    
                    <apex:selectOption itemLabel="JAVA" itemValue="j"/>
                    <apex:selectOption itemLabel="HTML" itemValue="h"/>  
                    <apex:selectOption itemLabel="JAVASCRIPT" itemValue="js"/>
                    <apex:selectOption itemLabel="VC++" itemValue="vcpp"/>         
                </apex:selectcheckboxes>     
            </apex:pageBlockSectionItem>
            <apex:pageBlockSectionItem>Active?<apex:inputCheckbox/></apex:pageBlockSectionItem>
        </apex:pageBlockSection>
        <apex:pageBlockButtons >
            <apex:commandButton value="Store"/>
        </apex:pageBlockButtons>
    </apex:pageBlock>
</apex:form>
</apex:page>

Output:



3 comments:

  1. good example but you have mention only user interface part what about if any want to save the data in custom object please provide controller class for this apex page and also mention how to create dropdown list in apex
    thanks

    ReplyDelete
    Replies
    1. You have to do some thing like this - http://www.infallibletechie.com/2013/08/storing-values-in-multi-select-picklist.html

      Delete