Hi I have a chronoform with two date pickers, set to use Y-m-d as date format.
I want to use javascript to get the duration in days between these two dates and then enter it as a hidden value in the form.
I have almost no knowledge of javascript (or for that matter of PHP0 but I am struggling with it).
I have put this
in the 'javascript bit of the form code.
The question is 1.
how do get from the form, the values of y1,m1,d1 and y2,m2,d2 to use with the javascrpt ?
question 2. how can I put the result as the value of the hidden element and
question 3. is my javascript code anything like correct !!
I will want also to check whether the first day is before today and reject the form if so
and to check that the second date is not before the first.
Help on these issues please. !! http://www.chronoengine.com/forums/posting.php?mode=post&f=2#
--
Dave
I want to use javascript to get the duration in days between these two dates and then enter it as a hidden value in the form.
I have almost no knowledge of javascript (or for that matter of PHP0 but I am struggling with it).
I have put this
var date1 = new date(y1,m1-1,d1);
var date2 = new date(y2,m2-1,d2);
var today = new date();
var oneday = 1000*60*60*24 ;
function duration(date1,date2){
return (date2-date1)/oneday +1;}
function errd1{
return (today > date1);
}
function errd2{
return (date1 > date2);
}
in the 'javascript bit of the form code.
The question is 1.
how do get from the form, the values of y1,m1,d1 and y2,m2,d2 to use with the javascrpt ?
question 2. how can I put the result as the value of the hidden element and
question 3. is my javascript code anything like correct !!
I will want also to check whether the first day is before today and reject the form if so
and to check that the second date is not before the first.
Help on these issues please. !! http://www.chronoengine.com/forums/posting.php?mode=post&f=2#
--
Dave