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
satheesh psatheesh p 

pass value checkbox if seleceted

Hi All,

i want to pass value if the checkbox is clicked.The below code is i am used

Visualforcepage

<apex:inputCheckbox value="{!isallbranch}" onchange="checkSelectedValue" selected ="true"/> All Branch
<apex:inputCheckbox value="{!isallbranch}" onchange="checkSelectedValue" /> Branch1

Apex

Public boolean isallbranch{get;set;} 
Public boolean myvalue{get;set;}
Public boolean myvalue1{get;set;}

public string checkSelectedValue(){ 
     if(!isallbranch == true)       
        System.debug('isallbranch value----- is true');   
        myvalue = "test";
       return myvalue;
    } 
       
    public PageReference pageLoad() {
     myvalue1 = checkSelectedValue();
     for(myobi__c mynobj :[ select field1__c,field2__c from myobj__c WHERE field1 = myvalue1] )
     { }
    }

is this possible or is there any alternative is available.give me a solution as soon as possible

Thank you..
Best Answer chosen by satheesh p
pavan501pavan501
Please check below example and mark solved if this helps

visualforce page: forder
<apex:page controller="fordercontroller">
<apex:form >

<apex:pageblock >
<apex:pageBlockSection >
<apex:inputcheckbox label="All Branch" value="{!firstval}">
<apex:actionSupport event="onchange" action="{!changeselectedvalue}" reRender="out"/>
</apex:inputCheckbox>

<apex:outputText id="out" value="{!output}"></apex:outputText>
</apex:pageBlockSection>
</apex:pageblock>

</apex:form>

</apex:page>
controller:
 
public with sharing class fordercontroller {

public string firstval{get;set;}
public string output{get;set;}

public void changeselectedvalue(){
output = firstval;
}

}
Thanks,
Pavan

 

All Answers

pavan501pavan501
Please check below example and mark solved if this helps

visualforce page: forder
<apex:page controller="fordercontroller">
<apex:form >

<apex:pageblock >
<apex:pageBlockSection >
<apex:inputcheckbox label="All Branch" value="{!firstval}">
<apex:actionSupport event="onchange" action="{!changeselectedvalue}" reRender="out"/>
</apex:inputCheckbox>

<apex:outputText id="out" value="{!output}"></apex:outputText>
</apex:pageBlockSection>
</apex:pageblock>

</apex:form>

</apex:page>
controller:
 
public with sharing class fordercontroller {

public string firstval{get;set;}
public string output{get;set;}

public void changeselectedvalue(){
output = firstval;
}

}
Thanks,
Pavan

 
This was selected as the best answer
satheesh psatheesh p
Thanks pavan