in PDCReport I'm using Javascript function to fill date range based on picklist value, the picklist values are : "Current FY,Next FY,Next Month ......." the javascript function is called when the picklist value changed, I used case statement to test the value of pickklist so I can fill the date input fields with the associated date, for example if "Next Month" selected in the picklist the following case will be executed :

       case "nm":{
           df= new Date(new Date().getFullYear(),new Date().getMonth()+1, 1);
           dt= new Date(new Date().getFullYear(),new Date().getMonth()+2, 0);
           fdateid.value = normalizeDateExtended(df);
           tdateid.value = normalizeDateExtended(dt);

where: - "fdateid" is the DOM ID of the date input field
- "normalizeDateExtended" is a function to format the date

my problem is that when the page loads for the first time the date range changed correctly from picklist, but when you click run report, the report runs correctly with the date range given from the picklist, but I can't change the date range from picklist until I reloads the full page. For example if you select current fy, the date range changed to 1/1/2016 to 12/31/2016 and then run the report, it runs correctly and give you cheques for this year, but now if you change the picklist value to eg. Next month the value in the inputfields remains 1/1/2016 to 12/31/2016. I worked hard with all possible solutions but nothing worked for me, but I figured out exactly where is the problem. Consider the following situation : the page loads and you select Current fy(1/1/2016 to 12/31/2016) and run the report, now the report ran for the first time, now change the picklist to previous fy(1/1/2015 to 12/31/2015) nothing changed in the input fields values, remain (2016) the strange thing now if you execute : "alert(fdateid.value)" you will get 1/1/2015 now we have in the input field fdateid :

value displayed in the field (1/1/2016)
value in controller (1/1/2016)
value returned from getelementbyid.value is (1/1/2015) witch is the correct

I tried to use rerender but this re assigns the value in the controller to the inputfield.


1 Answer 1


I'm not sure why do you implement it through JS. Maybe you can try to use actionSupport and change date in controller directly?

example VF:

<apex:actionRegion >
  <apex:inputfield value="{!Case.ContactId}" label="Contact" required="true"  >
    <apex:actionSupport event="onchange" action="{!ContactSelected}" rerender="EnvironmentList, AccountName"/>

example Controller:

public PageReference ContactSelected() {
  update some controller variable
  return null;

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .