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
mdinatalemdinatale 

How to set default on checkbox

I Have a checkbox that the default checked is set in the object. I created a visualforce page with the checkbox. But when i hit the new button it is not checked. How do i make the default value checked. Thanks

 

<apex:inputCheckbox value="{!Debt_Info__c.Round_Payment__c}" />

 

VPrakashVPrakash

Use selected attribute like 

 

 

<apex:inputCheckbox value="{!Debt_Info__c.Round_Payment__c}" selected ="true"/>
mdinatalemdinatale

That works if its new, but what if its on edit, even though its false it still comes up checked.

Chamil MadusankaChamil Madusanka

If it is your field's data type is Check box, You can assign the default value at the creating of the field. Then use apex:inputField in VF page.

 

If a reply to a post answers your question or resolves your problem, please mark it as the solution to the post so that others may benefit.

Meer SalmanMeer Salman

Have you used any controller or extension?? If yes then you can pass the default value for the checkbox in the constrcutor. And in the vfpage use your code it will work fine.