You need to sign in to do that
Don't have an account?
Prakhar Gupta
Action support Rerender not working
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
<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>
Thanks in advance.!!!
<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>
Thanks in advance.!!!
if standard then, you dont need to use apex:selectOptions if you are using standard picklist fields and standard dependent picklist fields
use <apex:inputField value="{!city1}"> etc.
No rerendering a1 aslo not working. Please suggest.
Thanks.
I am using custom login that has been written in "cities1" method of controller.
Thanks.
please put your controller class so that we can see what is your logic so if any error can find(Remove you sensitive data) and then post
here is the 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;
}
}
I tried this code on my Visualforce and it is working fine. My suspect is something interfering with your onchange? Is there any other javascript on the page. Check your javascript console for any errors. Or use the code below and start writing remaining code piece by piece.