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
Alfredo OrnelasAlfredo Ornelas 

Position of checkbox field on Visualforce page

Is there a way to change the position of the checkbox from the end of my field name to the beginning of the field name? below what I want to achieve...

User-added image
Best Answer chosen by Alfredo Ornelas
Agustina GarciaAgustina Garcia
Yes, you are repeting field names.

If you do this:
 
<apex:inputCheckbox value="{!Lead.Oil_and_Gas_Investor_Australia_Website__c}" label="Oil and Gas Investor Australia"/>

You are showing "Oid and Gas Investor Australia" and then the checkbox.

Try to do this for all
 
<apex:inputCheckbox value="{!Lead.AD_Watch__c}" />
<apex:outputText >Oil and Gas Investor</apex:outputText>

On the other side, in order to make the page thinks that this 2 tags are a single one, put both inside a SelectItem
 
<apex:pageblockSectionItem >
    <apex:inputCheckbox value="{!Lead.AD_Watch__c}" />
    <apex:outputText >Oil and Gas Investor</apex:outputText>
</apex:pageblockSectionItem>

 

All Answers

ManojjenaManojjena
Hi Alfredo Ornelas,

Post your code snipet so that we can help you solve your issue .
 
Agustina GarciaAgustina Garcia
Hi,

Not sure what you exactly need, but find bellow a screenshot with several examples and after that the code for each one. 

User-added image
 
<apex:page standardController="Account">
    <apex:form >
        <apex:pageBlock >
            <apex:pageBlockSection title="Account Information">
                    <apex:inputField value="{!account.name}" Label="Name"/>
                    <apex:inputField value="{!account.name}"/>
                    <apex:inputField value="{!account.site}"/>
                    <apex:inputCheckbox value="{!account.IsCustomerPortal}" />
            </apex:pageBlockSection>
            <apex:pageBlockSection title="Account Checkbox - Field and Checkbox">
                <apex:pageblockSectionItem >
                    <apex:inputField value="{!account.IsCustomerPortal}" />
                    <apex:inputCheckbox value="{!account.IsCustomerPortal}" />
                </apex:pageblockSectionItem>
            </apex:pageBlockSection>
            <apex:pageBlockSection title="Account Checkbox - Field and Checkbox2">
                <apex:pageblockSectionItem >
                    <apex:inputCheckbox value="{!account.IsCustomerPortal}" id="cb"/>
                    <apex:outputText >Checkbox</apex:outputText>
                </apex:pageblockSectionItem>
            </apex:pageBlockSection>
        </apex:pageBlock>
    </apex:form>
</apex:page>

Hope this helps.
Kiruthigha Rajasekaran 10Kiruthigha Rajasekaran 10
Hi Alfredo Ornelas,
I guess your question is when we use the below code the check box should be displayed before the field name.  Please confirm

<apex:inputCheckbox value="{!account.Match_Billing_Address__c}" />
Alfredo OrnelasAlfredo Ornelas
That's correct, I need to display the checkbox before the field name.
Agustina GarciaAgustina Garcia
Maybe you need a different look and feel, but what you need is done with the above code. Lines from 16 to 21.
Alfredo OrnelasAlfredo Ornelas
Agustina,
Can you help me with the syntax of my code?

User-added image


This is what I get...

User-added image
Agustina GarciaAgustina Garcia
Hi, I cannot see the code.

Could you copy-paste it here using the <> icon that is beside the one that helps you to upload pictures?

Agustina
Alfredo OrnelasAlfredo Ornelas
<apex:pageBlockSection title="Sign Up For These Trials:" collapsible="false" columns="2">

                  <apex:inputCheckbox value="{!Lead.AD_Watch__c}" label="A&D Watch"/>
                  <apex:inputCheckbox value="{!Lead.Midstream_Monitor__c}"/><apex:outputText >Midstream Monitor</apex:outputText>
                  <apex:inputCheckbox value="{!Lead.Oil_and_Gas_Investor__c}"/><apex:outputText >Oil and Gas Investor</apex:outputText>
                  <apex:inputCheckbox value="{!Lead.Oil_and_Gas_Investor_Australia_Website__c}" label="Oil and Gas Investor Australia"/><apex:outputText >Oil and Gas Investor Australia Website</apex:outputText>
                  <apex:inputCheckbox value="{!Lead.Midstream_Business_Trial__c}" label="Midstream Business"/><apex:outputText >Midstream Business</apex:outputText>
                  <apex:inputCheckbox value="{!Lead.Oil_and_Gas_Investor_This_Week__c}"/><apex:outputText >Oil and Gas Investor This Week</apex:outputText>
                  <apex:inputCheckbox value="{!Lead.Downstream_Business_Trial__c}" label="Downstream Business"/><apex:outputText >Downstream Business</apex:outputText>
                  <apex:inputCheckbox value="{!Lead.Subsea_Engineering_News__c}"/><apex:outputText >Subsea Engineering News</apex:outputText>
                  <apex:inputCheckbox value="{!Lead.Gulf_States_Petroleum_Directory__c}"/><apex:outputText >Gulf States Petroleum Directory</apex:outputText>
                  <apex:inputCheckbox value="{!Lead.Unconventional_Oil_and_Gas_Center__c}" label="Unconventional Oil & Gas Center"/><apex:outputText >Unconventional Oil and Gas Center</apex:outputText>
                  <apex:inputCheckbox value="{!Lead.North_American_Petroleum_Directory__c}" id="cb"/><apex:outputText >North American Petroleum Directory</apex:outputText>
<p><br></br></p>
                  
              </apex:pageBlockSection>

I think I'm repeating the field names???
Agustina GarciaAgustina Garcia
Yes, you are repeting field names.

If you do this:
 
<apex:inputCheckbox value="{!Lead.Oil_and_Gas_Investor_Australia_Website__c}" label="Oil and Gas Investor Australia"/>

You are showing "Oid and Gas Investor Australia" and then the checkbox.

Try to do this for all
 
<apex:inputCheckbox value="{!Lead.AD_Watch__c}" />
<apex:outputText >Oil and Gas Investor</apex:outputText>

On the other side, in order to make the page thinks that this 2 tags are a single one, put both inside a SelectItem
 
<apex:pageblockSectionItem >
    <apex:inputCheckbox value="{!Lead.AD_Watch__c}" />
    <apex:outputText >Oil and Gas Investor</apex:outputText>
</apex:pageblockSectionItem>

 
This was selected as the best answer
ManojjenaManojjena
HI Alfredo,
Use dir attribute with LTR value .
Check belwo link it will help !!
https://developer.salesforce.com/docs/atlas.en-us.pages.meta/pages/pages_compref_inputCheckbox.htm
Thanks 
Manoj
ManojjenaManojjena

HI Alfredo,

Try code like below .
Let me know if it helps !!
<apex:inputCheckbox value="{!Lead.Subsea_Engineering_News__c}"  dir="LTR"/><apex:outputText >Subsea Engineering News</apex:outputText>
Thanks 
Manoj
 
Alfredo OrnelasAlfredo Ornelas
Thanks Agustina, Now it looks perfect!!

User-added image