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
padmini sspadmini ss 

calling apex command button when checkbox is checked

Hi i want to call one apex method when an checkbox is clicked , 
My requirmnet is i have 2 vf pages and one controller.
in 1sr vf page when usere inserts 2 dates fileds and after that command button (submit) i am displaying custom report (data table).clicks exprot link i am passing the selected dates values to the same apex controller. to another vf page and i am getting correct result
now the requirmnet is after displaying the datatable there is one checkbox , when checkbox is checked in Vf page,i  want to make check in the Sobject record,(that i can do it), the main problem is i wnat to pass this check box also in the argument.
User-added image

My VF code:

<a href="/apex/SalesOrderSAPReportInExcel?fDate={!fDateStr}&tDate={!tDateStr}&chkbox={!StoreSelectCheckBox} " target="_blank" >
Export Here
Apex controller:in constructor
public SalesOrderReportGenerator(ApexPages.StandardController stdController) {
         String Dtext = System.currentPageReference().getParameters().get('Dtext');
        String fDate = System.currentPageReference().getParameters().get('fDate');
        String tDate = System.currentPageReference().getParameters().get('tDate'); 
     String chkbox=System.currentPageReference().getParameters().get('chkbox');
       system.debug('*************:'+ chkboxs);
       If(fDate != null && tDate != null){
            fromDate = Date.valueOf(fDate);
            toDate = Date.valueOf(tDate);

Submit function method:

public pageReference SalesOrderReportData() {

I can achive this only when checkbox checked and again subbmit commmad butoon called.

in simple words i want to call call apex command button when checkbox is check how to achive this pls tell me

Sameer Tyagi SFDCSameer Tyagi SFDC

Hi padmini ss, 

You can not directly pass argument in apex method  from VF page.

Please try using <apex:actionfunction  tag. 

when you click on checkbox, it will call a javascript method and your javascript method will call apex method through actionfunction.

Let me know if it works for you.

Hi Padmini,

You can use onclick javascript function in checkbox component, once user clicks on checkbox then just call controller method by using actionFunction.

Best Regards,