You need to sign in to do that
Don't have an account?

Get Checkbox state in controller Apex | Visualforce
Hello all, I have a checkbox in my visualforce page just like this :
<apex:inputCheckbox />
I want to be able in my controller, to see whether or not the checkbox is checked. I am making a query that is based on the checkbox's state. For example. This is the state if the checkbox is not selected.
select name from foo__c where id = contactid
if the checkbox is selected, I want my query to be something like this
select name from foo__c where id IN :allContactIds
I'm stuck on this. Any help?
Assuming that users click a button after checking the box.
<apex:inputcheckbox value="{!variable1}"
Here variable1 references controller class variable. After user clicks the button, in the action method you would check for if(variable1)
query1
else
query2
Saraag
you can use action support tag and in the controller method you can check if the value is true or false. PFB sample code: