Onchange

JavaScript and client side scripting.

Moderator: General Moderators

Post Reply
jauson
Forum Contributor
Posts: 111
Joined: Wed Oct 05, 2011 12:59 am

Onchange

Post 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!
User avatar
requinix
Spammer :|
Posts: 6617
Joined: Wed Oct 15, 2008 2:35 am
Location: WA, USA

Re: Onchange

Post by requinix »

And what's the problem with it?
jauson
Forum Contributor
Posts: 111
Joined: Wed Oct 05, 2011 12:59 am

Re: Onchange

Post by jauson »

I have field total result. and I want to show the result on it everytime I select dates in my two datetime.
User avatar
requinix
Spammer :|
Posts: 6617
Joined: Wed Oct 15, 2008 2:35 am
Location: WA, USA

Re: Onchange

Post 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.
jauson
Forum Contributor
Posts: 111
Joined: Wed Oct 05, 2011 12:59 am

Re: Onchange

Post 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.
Post Reply