0

i have attached the code.

Goods with Cats<apex:inputCheckbox value="{!Good_with_Cats_c.Good_with_Cats__c}"/> 
         High Need<apex:inputCheckbox value="{!HighNeed_c.HighNeed__c}"/>
         Non-shedder<apex:inputCheckbox value="{!Non_shedder_c.Non_shedder__c}"/>                               
         Kid Friendly<apex:inputCheckbox value="{!kid_friendly_c.kid_friendly__c}"/>  
         Predatory Tendencies<apex:inputCheckbox value="{!Predatory_Tendencies_c.Predatory_Tendencies__c}"/>    

controller:

public Boolean Good_with_Cats_c {get; set;}
public Boolean HighNeed_c {get; set;}
public Boolean kid_friendly_c {get; set;}
public Boolean Non_shedder_c {get; set;}
public Boolean Predatory_Tendencies_c {get; set;}
2
  • Why in value you are referring fields twice?? for eg. {!Good_with_Cats_c.Good_with_Cats__c} why not just use {!Good_with_Cats_c}??
    – Mr.Frodo
    Commented May 13, 2016 at 6:14
  • yeah i have used but its showing an error "Unknown property 'petwizardcontroller.Good_with_Cats__c' "
    – muralimano
    Commented May 13, 2016 at 6:21

1 Answer 1

2

Have fun with it

Visualforce page

<apex:page controller="displayAllCheckboxes">
  <apex:form >
    Goods with Cats<apex:inputCheckbox value="{!Good_with_Cats}"/>
    High Need<apex:inputCheckbox value="{!HighNeed}"/>
    Non-shedder<apex:inputCheckbox value="{!Non_shedder}"/>                               
    Kid Friendly<apex:inputCheckbox value="{!kid_friendly}"/>  
    Predatory Tendencies<apex:inputCheckbox value="{!Predatory_Tendencies}"/>
    <br/>
    <apex:commandButton value="Submit" action="{!Submit}"/>
  </apex:form>
  You select: {!selection}
</apex:page>

Apex class

public with sharing class displayAllCheckboxes {

    public List<String> Selection { get; set; }
    public Boolean Good_with_Cats {get; set;}
    public Boolean HighNeed {get; set;}
    public Boolean Non_shedder {get; set;}
    public Boolean kid_friendly {get; set;}
    public Boolean Predatory_Tendencies {get; set;}

    public void Submit() {
        Selection = new List<String>();
        if(Good_with_Cats == true) Selection.add('Good_with_Cats');
        if(HighNeed == true) Selection.add('High Need');
        if(Non_shedder == true) Selection.add('Non-shedder');
        if(kid_friendly == true) Selection.add('Kid Friendly');
        if(Predatory_Tendencies == true) Selection.add('Predatory Tendencies');
    }
}

Result

enter image description here

3
  • Have you get the answer of original question?
    – Cray Kao
    Commented May 13, 2016 at 6:43
  • yes but i need to search the datas according to the checkbox selected values (Object Name Characteristics ,API Name Characteristics__c) cray
    – muralimano
    Commented May 13, 2016 at 7:04
  • 1
    @muralimano If you have got the answer you should mark it correct.If you have another question ask it in another thread.
    – Mr.Frodo
    Commented May 13, 2016 at 7:29

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .