[SOLVED] button code to calculate time between two times |
12/16/2022 8:45:05 AM |
PHPRunner General questions | |
N
nagate816 authorDevClub member
Hello, Yesterday I got code similar to the code below to work and then copied a bunch of other things around on the form and somehow deleted the code that worked :( Anyway I have a start time and end time fields and I want to calculate the elapsed time between them. Here is my button code: // Put your code here. var varstart = Runner.getControl(pageid, 'StartTime'); var timestart = new Date("01-01-2020 " + varstart.getValue()); varhoursworked.setValue((+timeend.getValue())-(+timestart.getValue())); // params["txt"] = "Hello"; return false; This was the last version I saved before I got it to work witrh the changes I thougth I made to get it to work and I know it comes out in miliseconds but at the mement the code above does not seem to do anything. Anyoen see what I'm missing ? Thanks, Neil. |
|
![]() |
Sergey Kornilov admin 12/16/2022 |
Really hard to tell what might be wrong without having access to the project. Are there any Javascript errors there? You can see them in the Chrome Developer Tools: |
N
|
nagate816 authorDevClub member 1/10/2023 |
I worked this out so in case it's hjelpful to others, this code is in the Client Before event oif a button where StartTiem and End Time are Time Fields and HoursWorked is a numeric field. Here's the code that works: // Put your code here. Thanks, Neil. |