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
Steve Gilbert 13Steve Gilbert 13 

creating a checkbox in a visualforce page

I am researching how I can add a check box field to a current VF page and controller. This is just a simple "do you use...." yes/no box. Any ideas would be great.
Thanks for any ideas. 
Best Answer chosen by Steve Gilbert 13
Waqar Hussain SFWaqar Hussain SF
You can use apex:inputCheckbox attribute on VF page.

See Example
<apex:page Controller="PageController">
    <apex:form id="changePrivacyForm">
        <apex:pageBlock>
            <apex:pageMessages />
            <apex:pageblockSection>
                <apex:pageblockSectionItem>
                    <apex:outputText value="Do You Use VF?" />
                </apex:pageblockSectionItem>
                <apex:pageblockSectionItem>
                    <apex:inputCheckbox value="{!CheckBoxValue}" />
                    <apex:pageblockSectionItem>
            </apex:pageBlockSection>
        </apex:pageBlock>
    </apex:form>
</apex:page>
 
Public Class PageController {
    public boolean  CheckBoxValue {
        get;
        set;
    }

    public PageController() {

    }
}

 

All Answers

Waqar Hussain SFWaqar Hussain SF
You can use apex:inputCheckbox attribute on VF page.

See Example
<apex:page Controller="PageController">
    <apex:form id="changePrivacyForm">
        <apex:pageBlock>
            <apex:pageMessages />
            <apex:pageblockSection>
                <apex:pageblockSectionItem>
                    <apex:outputText value="Do You Use VF?" />
                </apex:pageblockSectionItem>
                <apex:pageblockSectionItem>
                    <apex:inputCheckbox value="{!CheckBoxValue}" />
                    <apex:pageblockSectionItem>
            </apex:pageBlockSection>
        </apex:pageBlock>
    </apex:form>
</apex:page>
 
Public Class PageController {
    public boolean  CheckBoxValue {
        get;
        set;
    }

    public PageController() {

    }
}

 
This was selected as the best answer
Steve Gilbert 13Steve Gilbert 13
Thanks
Shruti SShruti S
Could you give me the existing Controller and the VF Page code?