I have created a dependent pick list. I am populating the cities name based on the state but it is not working here is my code
Page
<apex:pageBlock Title="New Case" mode="edit" id="Block">
<apex:pageBlockSection title="Case Information" id="Block1" columns="2">
<apex:pageblockSectionItem >
<apex:outputLabel value="Status"/>
<apex:outputText value="New"/>
</apex:pageblockSectionItem>
<apex:pageblockSectionItem >
<apex:outputLabel value="Priority"/>
<apex:selectList size="1" value="{!priority}">
<apex:selectOptions value="{!priorities}"/>
</apex:selectList>
</apex:pageblockSectionItem>
<apex:pageblockSectionItem >
<apex:outputLabel value="State"/>
<apex:selectList size="1" value="{!state1}">
<apex:selectOptions value="{!states1}"/>
<apex:actionSupport event="onchange" reRender="a"/>
</apex:selectList>
</apex:pageblockSectionItem>
<apex:outputPanel id="a">
<apex:pageblockSectionItem >
<apex:outputLabel value="City"/>
<apex:selectList size="1" value="{!city1}" id="a1">
<apex:selectOptions value="{!cities1}"/>
</apex:selectList>
</apex:pageblockSectionItem>
</apex:outputPanel>
</apex:pageBlockSection>
Controller code
public class Sample {
public List<SelectOption> getStates1()
{
List<SelectOption> options = new List<SelectOption>();
options.add(new SelectOption('None','--- None ---'));
options.add(new SelectOption('TN','Tamil Nadu'));
options.add(new SelectOption('KL','Kerala'));
return options;
}
public List<SelectOption> getCities1()
{
List<SelectOption> options = new List<SelectOption>();
if(state == 'TN')
{
options.add(new SelectOption('CHE','Chennai'));
options.add(new SelectOption('CBE','Coimbatore'));
}
else if(state == 'KL')
{
options.add(new SelectOption('COA','Coachin'));
options.add(new SelectOption('MVL','Mavelikara'));
}
else
{
options.add(new SelectOption('None','--- None ---'));
}
return options;
}
}
Thanks in Advance. !!!