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
RishavRishav 

I want to update my outputpanel field on the basis of selected checkboxes value;

i want  to update my output panel after checking the chckbox but i am unable to do it  . help me.

<apex:page controller="test2">
<apex:form >
<apex:selectCheckboxes value="{!countries}">
<apex:selectOptions value="{!country}"></apex:selectOptions>
<apex:actionSupport reRender="zip" event="onchange" action="{!test}"/>
</apex:selectCheckboxes>
<apex:outputPanel id="zip">
hello  {!name}
</apex:outputPanel>
</apex:form>
</apex:page>

--------------------------------------------
public class test2 {
public string countries{get;set;}
  public string name {get;set;}

    public test2()
    {
      counter = 0;
    }

public list<selectoption> getcountry()
{
    list<selectoption>options = new list<selectoption>();
       options.add(new selectoption('india','india'));
      
       return options;
}

   public pageReference test()
   {
     if(countries == 'India')
     {
       name= ' kumar';
      }
      return null;
   }
}

Best Answer chosen by Rishav
GeniuanGeniuan
Hi Rishav, I noticed countries is a list, so based in the apex:selectCheckboxes help I got to this:

<apex:page controller="test2">
<apex:form >
<apex:selectCheckboxes value="{!countries}">
<apex:selectOptions value="{!country}"></apex:selectOptions>
<apex:actionSupport reRender="zip" event="onchange" action="{!test}"/>
</apex:selectCheckboxes>
</apex:form>
<apex:outputPanel id="zip">
hello  {!name}
</apex:outputPanel>
</apex:page>


-------------------------


public class test2 {
public integer counter{get;set;}
String[] countries = new String[]{};
  public string name {get;set;}

    public test2()
    {
      counter = 0;
    }

public list<selectoption> getcountry()
{
    list<selectoption>options = new list<selectoption>();
       options.add(new selectoption('india','india'));
     
       return options;
}

   public pageReference test()
   {
     if(!countries.isEmpty() && countries[0] == 'india')
     {
       name= ' kumar';
      }
      return null;
   }
    public String[] getCountries() {
        return countries;
    }
    public void setCountries(String[] countries) {
        this.countries = countries;
    }
}

All Answers

Ramu_SFDCRamu_SFDC
Wrap the code between action region and give a try. For more information refer to the below article

http://www.salesforce.com/us/developer/docs/pages/Content/pages_compref_actionRegion.htm
RishavRishav
Hello Ramu_SFDC 
                                   This is not the solution of my problem.
GeniuanGeniuan
Hi Rishav, I noticed countries is a list, so based in the apex:selectCheckboxes help I got to this:

<apex:page controller="test2">
<apex:form >
<apex:selectCheckboxes value="{!countries}">
<apex:selectOptions value="{!country}"></apex:selectOptions>
<apex:actionSupport reRender="zip" event="onchange" action="{!test}"/>
</apex:selectCheckboxes>
</apex:form>
<apex:outputPanel id="zip">
hello  {!name}
</apex:outputPanel>
</apex:page>


-------------------------


public class test2 {
public integer counter{get;set;}
String[] countries = new String[]{};
  public string name {get;set;}

    public test2()
    {
      counter = 0;
    }

public list<selectoption> getcountry()
{
    list<selectoption>options = new list<selectoption>();
       options.add(new selectoption('india','india'));
     
       return options;
}

   public pageReference test()
   {
     if(!countries.isEmpty() && countries[0] == 'india')
     {
       name= ' kumar';
      }
      return null;
   }
    public String[] getCountries() {
        return countries;
    }
    public void setCountries(String[] countries) {
        this.countries = countries;
    }
}

This was selected as the best answer
RishavRishav
Hi Geniuan ,
                             thanks for your response, yes you are correct, i was making mistake by treting a list as a string but later i corrected it in the same fashion as you have described.