It's simple, your button must call an apex method on the page controller.
This method will retrieve the object that you want to change and modify the checkbox.
Here's an example:
SimpleObject is a Custom Object that its only field is Check.
SimpleObject {
CheckBox Check;
}
Apex Page: CheckBoxExample.page
*************************************************************************
<apex:page controller="CheckBoxExampleControl" >
<apex:form >
<apex:commandButton value="Check All" action="{!checkAll}"/>
<apex:commandButton value="Uncheck All" action="{!uncheckAll}"/>
</apex:form>
</apex:page>
*************************************************************************
Controler: CheckBoxExampleControl.cls
*************************************************************************
public with sharing class CheckBoxExampleControl {
public PageReference checkAll(){
/* Get All the Objects */
List<SimpleObject__c> objs = [SELECT Check__c FROM SimpleObject__c];
/* Check all Check Field */
for(SimpleObject__c obj: objs)
obj.Check__c = true;
update objs;
return null;
}
public PageReference uncheckAll(){
/* Get All the Objects */
List<SimpleObject__c> objs = [SELECT Check__c FROM SimpleObject__c];
/* Uncheck all Check Field */
for(SimpleObject__c obj: objs)
obj.Check__c = false;
update objs;
return null;
}
}
*************************************************************************
Now if you go to the page: yourdomain/apex/checkboxexample, you will see a page with two buttons, Check All and Uncheck All, if you click one of these, all the SimpleObjects will have the Check field selected or not, depending on what have you clicked. This is just an example, you may edit, modify and use as you want.
If this is not what are you looking for, please provide more information and i'll be happy to help.
Thank you for your reply. I'm not exactly sure what to do with the apexi code.
I currently have one button called "Create Job" when this is clicked I want a tickbox called "Job_Created" to be enabled and another screen to display. I have got the next page to display but the checkbox never gets enabled. I assume I want to use "onclick javascript" but I am unsure of the code.
Check out this thread.
Hope that helps,
Sati
It's simple, your button must call an apex method on the page controller.
This method will retrieve the object that you want to change and modify the checkbox.
Here's an example:
SimpleObject is a Custom Object that its only field is Check. SimpleObject { CheckBox Check; } Apex Page: CheckBoxExample.page ************************************************************************* <apex:page controller="CheckBoxExampleControl" > <apex:form > <apex:commandButton value="Check All" action="{!checkAll}"/> <apex:commandButton value="Uncheck All" action="{!uncheckAll}"/> </apex:form> </apex:page> ************************************************************************* Controler: CheckBoxExampleControl.cls ************************************************************************* public with sharing class CheckBoxExampleControl { public PageReference checkAll(){ /* Get All the Objects */ List<SimpleObject__c> objs = [SELECT Check__c FROM SimpleObject__c]; /* Check all Check Field */ for(SimpleObject__c obj: objs) obj.Check__c = true; update objs; return null; } public PageReference uncheckAll(){ /* Get All the Objects */ List<SimpleObject__c> objs = [SELECT Check__c FROM SimpleObject__c]; /* Uncheck all Check Field */ for(SimpleObject__c obj: objs) obj.Check__c = false; update objs; return null; } } *************************************************************************
Now if you go to the page: yourdomain/apex/checkboxexample, you will see a page
with two buttons, Check All and Uncheck All, if you click one of these, all the
SimpleObjects will have the Check field selected or not, depending on what have
you clicked.
This is just an example, you may edit, modify and use as you want.
If this is not what are you looking for, please provide more information and i'll be happy to help.
Regards,
Ezequiel
Thank you for your reply. I'm not exactly sure what to do with the apexi code.
I currently have one button called "Create Job" when this is clicked I want a tickbox called "Job_Created" to be enabled and another screen to display. I have got the next page to display but the checkbox never gets enabled. I assume I want to use "onclick javascript" but I am unsure of the code.
Hope that makes sense?
Thanks.
Here is the link I would like loading: https://na6.salesforce.com/a06/e?retURL=%2Fa06%2Fo with a check box being enabled.
Thanks,
Hi rob, i'm afraid i do not understand exactly what you need (the link is user related).
Please provide me with more detail and maybe some screenshots and i'll do my best to adapt my code to your needs.