Page 1 of 1

Onchange

Posted: Tue Jun 26, 2012 11:43 pm
by jauson
Hi,

Can somebody help me to automate the total of hours on my field.

ex I have 3 fields

datetime1 = textfield
datetime2 = textfield
total = textfield

I want to show the result in my total field when I select the date/time in my datetime1 and datetime2 it should be automated field.. below is my code..

$date1 = new DateTime($textFromDate);
$date2 = new DateTime($textToDate);

$diff = $date2->diff($date1);

$hours = $diff->h;
$hours = $hours + ($diff->d*8);

$total = $hours / $per_day;

Thank you very much!

Re: Onchange

Posted: Wed Jun 27, 2012 2:58 am
by requinix
And what's the problem with it?

Re: Onchange

Posted: Wed Jun 27, 2012 11:44 pm
by jauson
I have field total result. and I want to show the result on it everytime I select dates in my two datetime.

Re: Onchange

Posted: Thu Jun 28, 2012 3:04 am
by requinix
Okay, well, you've got that $total variable there with (presumably) what you want to show, so... echo it out. Or be a lot more descriptive about what you're trying to do, because neither "show the result" nor "everytime I select dates in my two datetime" really means anything.

Re: Onchange

Posted: Thu Jun 28, 2012 4:04 am
by jauson
yeah your right! but I want to add some effects on my $total field. I want it to be live, when I change my dates it always change too.