Wednesday, August 13, 2014

19) Listbox using visualforce

<apex:page Controller="Listbox">
<apex:form >
<left>
<apex:pageBlock >
<b>Category:&nbsp;&nbsp;</b>
<apex:selectList value="{!ctgry}" size="1">
<apex:selectOptions value="{!ctgrys}"/>
</apex:selectList>  
</apex:pageBlock>
</left>
</apex:form> 
</apex:page>

public class Listbox
{

    public String[] ctgry = new String[]{};
 
    public Listbox()
    {

    }
 
    public List<SelectOption> getCtgrys()
    {  
      List<SelectOption> options = new List<SelectOption>();
      options.add(new SelectOption('India','India'));
      options.add(new SelectOption('CANADA','Canada'));
      options.add(new SelectOption('United States','US'));
      return options;
    }
 
    public String[] getCtgry()
    {
      return ctgry;
    }
 
    public void setCtgry(String[] ctgry)
    {
    this.ctgry = ctgry;
    }  

}


No comments: