Sunday, 3 February 2013

How to show more years in salesforce datepicker years list(options)

Hi,

Today I have a small requirment that is to show upto 100 years in year list of  salesforce default date picker.
I tried a lot and in last i find a small script by which we can do this

just use this script  and see the magic

<script>
  (function() {
    var windowOnload = window.onload;
    window.onload = function() {
      if (windowOnload) windowOnload();
      var select = document.getElementById('calYearPicker');
      if (!select) return;

      select.innerHTML = '';
      var startYear = new Date().getFullYear() - 100;
      for (var year = startYear; year < startYear + 120; year++) {
        select.appendChild(new Option(year, year));
      }
    }
  }());
</script>
Now you can see the magic on page where i put the script on page and showing a date field and list of years


I hope this will help you in many cases
Thanks
Ashlekh Gera

No comments:

Post a Comment