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
JR NonprofitJR Nonprofit 

Retrieving checked items

I am working with the sample code in the Apex manual dealing with the selectoptions class on pages 187-189 in the Apex reference guide.  I am trying to add something to this code from the guide:
 

public class sampleCon {

String[] countries = new String[]{};

public PageReference test() {

return null;

}

public List<SelectOption> getItems() {

List<SelectOption> options = new List<SelectOption>();

options.add(new SelectOption('US','US'));

options.add(new SelectOption('CANADA','Canada'));

options.add(new SelectOption('MEXICO','Mexico'));

return options;

}

public String[] getCountries() {

return countries;

}

public void setCountries(String[] countries) {

this.countries = countries;

}

}

Using the examples, I have no problem displaying on the page the values of the items checked.

However, I am trying to extract the values via code in the controller from the selectoptions that have been checked.  I think this is possible in the getCountries() method, but I can't seem to figure out how to do it.  Is it possible for someone to help me with the couple of lines of code necessary to make this happen?

Thanks for your help.

 

T

 

I am working with the sample code in the Apex manual dealing with the selectoptions class on pages 187-189 in the Apex reference