+ Start a Discussion

Dropdown values within javascript



When i am using this code


   <apex:facet name="header">Dec-09</apex:facet>
   <apex:inputField id="dec" style="width:80px" value="{!input.Dec__c}"/>


I am getting a dropdown values for Dec-09 from salesforce database,


Now i have to create a javascript function and i need to get the values mentioned above within this function. how do i do that.

Can anyone help me.




Message Edited by gprasuna on 02-05-2009 06:16 AM

I think you are going to need to use the  "describe" functionality of Apex to generate the a list of picklist values for a specific field. Then pass that list to the VF page as a property and have your javascript iterate across the entire list of values.


Here is a 2 line example of getting a list of picklist values for the standard Account object, Rating picklistfield:


Schema.DescribeFieldResult F = Account.Rating.getDescribe(); List<Schema.PicklistEntry> ratingPicklistValues= F.getPicklistValues();


More information here on dynamic apex.



Unless you just want the value a user selects from the <apex:inputField>, then you can use the actionFunction or actionSupport components of VF to pass that value.