You need to sign in to do that
Don't have an account?
MMuneee
i need to select both picklist and save them
Visual force page
==============
<apex:page controller="ctlDepPickLst" tabStyle="Account">
<apex:form >
<apex:pageBlock >
<apex:pageBlockButtons >
</apex:pageBlockButtons>
<apex:pageBlockSection columns="2">
<apex:pageblockSectionItem >
<apex:outputLabel value="Country"/>
</apex:pageblockSectionItem>
<apex:pageblockSectionItem >
<apex:selectList size="1" value="{!country}">
<apex:selectOptions value="{!countries}"/>
<apex:actionSupport event="onchange" reRender="a"/>
</apex:selectList>
</apex:pageblockSectionItem>
<apex:pageblockSectionItem >
<apex:outputLabel value="State"/>
</apex:pageblockSectionItem>
<apex:pageblockSectionItem >
<apex:selectList size="1" value="{!state}" id="a">
<apex:selectOptions value="{!states}"/>
</apex:selectList>
</apex:pageblockSectionItem>
</apex:pageBlockSection>
</apex:pageBlock>
<apex:pageBlock >
</apex:pageBlock>
</apex:form>
</apex:page>
Custom Controller
------------------------===
public class ctlDepPickLst {
public String country {get;set;}
public String state {get;set;}
public PageReference Save()
{
return null;
}
public List<SelectOption> getCountries()
{
List<SelectOption> options = new List<SelectOption>();
options.add(new SelectOption('None','--- Select ---'));
options.add(new SelectOption('US','United States'));
options.add(new SelectOption('IN','India'));
return options;
}
public List<SelectOption> getStates()
{
List<SelectOption> options = new List<SelectOption>();
if(country == 'US')
{
options.add(new SelectOption('CO','Colorado'));
options.add(new SelectOption('NE','Nevada'));
options.add(new SelectOption('TE','Texas'));
}
else if(country == 'IN')
{
options.add(new SelectOption('AP','Andrapradesh'));
options.add(new SelectOption('TS','Telangana'));
options.add(new SelectOption('TM','Tamilnadu'));
}
else
{
options.add(new SelectOption('None','--- Select ---'));
}
return options;
}
}
i need save button in below code.can you update both vf and custom logic for below code
i need to select both picklist and save them
Visual force page
==============
<apex:page controller="ctlDepPickLst" tabStyle="Account">
<apex:form >
<apex:pageBlock >
<apex:pageBlockButtons >
</apex:pageBlockButtons>
<apex:pageBlockSection columns="2">
<apex:pageblockSectionItem >
<apex:outputLabel value="Country"/>
</apex:pageblockSectionItem>
<apex:pageblockSectionItem >
<apex:selectList size="1" value="{!country}">
<apex:selectOptions value="{!countries}"/>
<apex:actionSupport event="onchange" reRender="a"/>
</apex:selectList>
</apex:pageblockSectionItem>
<apex:pageblockSectionItem >
<apex:outputLabel value="State"/>
</apex:pageblockSectionItem>
<apex:pageblockSectionItem >
<apex:selectList size="1" value="{!state}" id="a">
<apex:selectOptions value="{!states}"/>
</apex:selectList>
</apex:pageblockSectionItem>
</apex:pageBlockSection>
</apex:pageBlock>
<apex:pageBlock >
</apex:pageBlock>
</apex:form>
</apex:page>
Custom Controller
------------------------===
public class ctlDepPickLst {
public String country {get;set;}
public String state {get;set;}
public PageReference Save()
{
return null;
}
public List<SelectOption> getCountries()
{
List<SelectOption> options = new List<SelectOption>();
options.add(new SelectOption('None','--- Select ---'));
options.add(new SelectOption('US','United States'));
options.add(new SelectOption('IN','India'));
return options;
}
public List<SelectOption> getStates()
{
List<SelectOption> options = new List<SelectOption>();
if(country == 'US')
{
options.add(new SelectOption('CO','Colorado'));
options.add(new SelectOption('NE','Nevada'));
options.add(new SelectOption('TE','Texas'));
}
else if(country == 'IN')
{
options.add(new SelectOption('AP','Andrapradesh'));
options.add(new SelectOption('TS','Telangana'));
options.add(new SelectOption('TM','Tamilnadu'));
}
else
{
options.add(new SelectOption('None','--- Select ---'));
}
return options;
}
}
Since you have already included
Why don't you simply include attribute location="bottom" like this
and include your save button inside this tag.
And use apex:commandButton , let me know if you have issues.