This topic is locked
[SOLVED]

 Extract year from date

8/1/2014 9:30:24 AM
PHPRunner General questions
C
cristi author

I have two fields: one of date type in which the user enters the date and another where if the user clicks on it the year from the date field is automatically inserted.
The problem is that every time that I try to do this I receive a "NaN" value for the year.
On javascript onload event I have this:

var date=Runner.getControl(pageid, 'Data');

var year=Runner.getControl(pageid, 'Anul');
var oneyear=new Date(date.getValue());
function func() {
year.setValue(oneyear.getFullYear());
};
year.on('click', func);


Edit:
I figured out - I need to populate the oneyear variable inside the function otherwise there is no value in this variable