PDA

View Full Version : Calc Elapsed Time between 2 form fields



kevin_dalby
11-08-2007, 07:19 PM
i have a form with 3 fields. field1 is the start time of a logged event, field2 is the end time of the event, field 3 is the elapsed time between the two field values.

when I double click on the elapsed time field i'd like to calculate the elapsed time in hours.

i have a double-click event that will call the function i'm looking for. I want the function to push the value into the elapsed time field.

so in pseudo code:

on double-click:

take time value (military time) in END form field and subtract time value from field START and set document.form.["myform"].elapsed= results

i'm having problems doing this the way i think it should be - firefox gives me error msgs about getHours() not being a valid function

any help appreciated, minimal lines of code please

thanks
kevin

boogyman
11-08-2007, 07:27 PM
Post a URL to the problematic site or post the code
its much easier if we just need to modify a script then for us to re-create something that you have already done.
if you are going to post code please encapsulate it within [code] tags

kevin_dalby
11-09-2007, 06:51 PM
Post a URL to the problematic site or post the code
its much easier if we just need to modify a script then for us to re-create something that you have already done.
if you are going to post code please encapsulate it within [code] tags

sorry, no code or site ....

i'm going to approach it using vbscript for now so that it happens during the POST operation but, i'd really like it if i could make it happen live.

the vbscript in the form will basically do this on POST:

elapsed.value=datediff("h", EndTime, StartTime)

that's what i'm trying to have happen on a double click in the field

thanks,
Kevin