You need to sign in to do that
Don't have an account?
Sharathbabu K
adding values dynamically to the picklist
HII Freinds am bit new to salesforce,
I have an state__c sObject,if i create any sate in my state__c,created value should add dynamically to the pickist in visuaForce page
Any help would be greatly appriciated
I have an state__c sObject,if i create any sate in my state__c,created value should add dynamically to the pickist in visuaForce page
Any help would be greatly appriciated
Hi Sharathbabu,
Please try the above code matching your requirement criteria.
VF Page:
<apex:page controller="dynamicpicklistt">
<apex:form>
<apex:pageblock>
<apex:pageblocksection>
<apex:outputlabel value="state" for="values" />
<apex:selectList value="{!satesize="1" id="values" >
<apex:actionSupport event="onchange" action="{!satetaction}" reRender="pb"/>
<apex:selectOptions value="{!stateNames}"/>
</apex:selectList>
</apex:pageblocksectionItem>
</apex:pageblock>
</apex:form>
</apex:page>
Controller Page :
public dynamicpicklistt()
{
LocationNames = new List<selectoption>();
LocationNames.add(new selectoption('Select state','Select state'));
for(state__c l : [Select Id, Name FROM state__c])
{
LocationNames.add(new selectoption(l.id,l.name));
}
}
Thanks,
Please mark it as solved if it helps you.......................
All Answers
Hi Sharathbabu,
Please try the above code matching your requirement criteria.
VF Page:
<apex:page controller="dynamicpicklistt">
<apex:form>
<apex:pageblock>
<apex:pageblocksection>
<apex:outputlabel value="state" for="values" />
<apex:selectList value="{!satesize="1" id="values" >
<apex:actionSupport event="onchange" action="{!satetaction}" reRender="pb"/>
<apex:selectOptions value="{!stateNames}"/>
</apex:selectList>
</apex:pageblocksectionItem>
</apex:pageblock>
</apex:form>
</apex:page>
Controller Page :
public dynamicpicklistt()
{
LocationNames = new List<selectoption>();
LocationNames.add(new selectoption('Select state','Select state'));
for(state__c l : [Select Id, Name FROM state__c])
{
LocationNames.add(new selectoption(l.id,l.name));
}
}
Thanks,
Please mark it as solved if it helps you.......................
Thanks for the reply your code was helpfull its working.