I've written a vf page and try to send value from vf page to controller. The all checkbox is multiselect and it will use as filter on VF page. so it should be filter the record dynamically.

when i select the checkbox, i'm getting the checkbox value in controller but when i deselect the checkbox then also i'm getting value in controller. but i want when i deselect the checkbox the value in controller should be null.

and another is In controller i've to take the value from vf page and add to list. when i select two checkbox the first value in the list is replaced by the second value. means previous value is replacing in list. my apex code;

<apex:page sidebar="true" controller="Student_Controller">
<apex:form >
<script type="text/javascript">
   function doSearch(a) 

 <apex:pageBlock >
 <apex:actionFunction name="UpdateUser" action="{!SearchJob}" reRender="" >
    <apex:param name="param1" value="" />

 <div id="category" style="">Category: <br/>
    <apex:selectcheckboxes layout="pagedirection" value="{!ProductName}" onchange="doSearch(this.value);" style="">                   
        <apex:selectoptions value="{!ProductNames}" />  



public with sharing class Student_Controller {

public List<string> ProductName{get;set;}
public list<string> lst{get;set;}

public Student_Controller(){
 ProductName = New String[]{};

 public List<selectoption> getProductNames() 
list<selectoption> options = new list<selectoption>{New SelectOption('','Select')};            

//Product Name is a MultiSelect Picklist               
options.add(new SelectOption('1', '1'));

return options; 

 public PageReference SearchJob() {

 String SearchCompany =   Apexpages.currentPage().getParameters().get('param1');
  system.debug('^^^^^^^^^^^^^^^^^^^^^^^^^^'+SearchCompany );
  lst = new list<string>();
  lst.add(SearchCompany );
 return null;

Please help to sort out the problem...

  • What you want to get in SearchCompany variable?
    – Saroj Bera
    Nov 30, 2016 at 12:34

1 Answer 1


When they are actually rendered, apex:selectcheckboxes are actually a bunch of individual checkboxes with no relationship to each other, and the "onchange" event is copied to each one. So, when you click any box, it fires your javascript function with its own value, without regard to any other values.

Assuming you need to use apex:actionfunction, you can change your javascript function to select all the checkboxes and add them to a delimited string to pass to your function.

You must log in to answer this question.

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