This topic is locked
[SOLVED]

 Can we change the initial calendar year?

12/1/2010 9:31:27 AM
PHPRunner General questions
K
karmacomposer author

When someone needs to enter a data, can we change the calendar year dropdown to start at the current year? Now it starts at 1910.
Mike

J
Jane 12/1/2010

Hi,
unfortunately it's not possible to change year radius for separate field only.

You can change year radius for all fields in the PHPRunner5.2/source/include/common/runnerJS/DateFieldControl.js file: find and edit code for addYearOptions function.
We've added year radius for each field in PHPRunner 5.3.

K
karmacomposer author 12/1/2010



Hi,
unfortunately it's not possible to change year radius for separate field only.

You can change year radius for all fields in the PHPRunner5.2/source/include/common/runnerJS/DateFieldControl.js file: find and edit code for addYearOptions function.
We've added year radius for each field in PHPRunner 5.3.


OK. So I would have to use PHPRunner 5.3 to make that choice a bit easier for me. OK. I will save a backup project and try it on that.
Mike

K
karmacomposer author 12/2/2010

Since PHPRunner 5.3 gives me real problems with my current project, I cannot use it.
Here is an excerpt from that file:
/**

  • Overrides parent constructor
  • @param {Mixed} cfg

    */

    constructor: function(cfg){

    cfg.stopEventInit=true;

    // call parent

    Runner.controls.DateDropDown.superclass.constructor.call(this, cfg);

    //Overrides value elem. For handling 3 dropdowns

    this.valueElem = {

    "day": $("#day"+this.valContId),

    "month": $("#month"+this.valContId),

    "year": $("#year"+this.valContId)

    };
    // initialize control disabled

    if (cfg.disabled===true || cfg.disabled==="true"){

    this.setDisabled();

    }

    // get default value

    this.defaultValue = this.getValue();

    // use onchange instead onblur for DD

    this.addEvent(["change"]);

    // onblur not usable

    this.killEvent("blur");

    //event elems

    this.elemsForEvent = [this.valueElem["day"].get(0), this.valueElem["month"].get(0), this.valueElem["year"].get(0)];

    // init events handling

    this.init();

    // add hidden elems

    this.hiddElemId = this.valContId;//"value"+this.goodFieldName+""+this.id;

    this.hiddValueElem = $("#"+this.hiddElemId);

    // add input type attr

    this.inputType = "3dd";

    // if allready have constants, than fill combos

    if (window.TEXT_MONTH_JAN){

    this.addYearOptions(cfg.yearVal);

    this.addMonthOptions(cfg.monthVal);

    this.addDayOptions(cfg.dayVal);

    }

    },
    destructor: function(){

    this.valueElem['day'].remove();

    this.valueElem['month'].remove();

    this.valueElem['year'].remove();

    },

    /**
  • Add year options
  • @param {integer} year value

    */

    addYearOptions: function(selectedYear) {

    this.valueElem["year"].html('');
    var dt = new Date();

    var currentYear = dt.getFullYear();

    var startYear = currentYear-100;

    var endYear = currentYear+10;

    var opt = document.createElement('OPTION');

    $(opt).val('').html('');

    this.valueElem["year"].append(opt);
    for(var i = startYear; i<=endYear; i++){

    var opt = document.createElement('OPTION');

    $(opt).val(i).html(i);

    if (i==selectedYear){

    opt.selected = true;

    }

    this.valueElem["year"].append(opt);

    };

    this.addYearOptions = Runner.emptyFn;

    },
    Is the line of code to change the default starting date in there? If so, which one? How do I set it to the current year?
    If not, what line or lines do I need to focus on? How do I change it to default to the current year.
    Mike

J
Jane 12/3/2010

Find and edit this line:

var startYear = currentYear-100;
K
karmacomposer author 12/7/2010



Find and edit this line:

var startYear = currentYear-100;



I marked as solved too soon.
Yes, this makes it more current, but also makes it impossible to choose birth dates for most people if you choose less than 90!
Perhaps I am not asking the right question. Yes, a 100 year spread is a good idea (current year - 100), however, what I am asking is:
Can we START the drop down and calendar on the current year for choosing dates? Right now, with -100 as the current year, it start at 1910. This is not good for 99.99% of the date picking (except for birth dates).
Hope the question is more obvious now.
Mike