 |
 |
 |
|
It is currently Wed Feb 20, 2019 8:49 am
|
|
Page 1 of 1
|
[ 5 posts ] |
|
Sub String in Developer Edition
Author |
Message |
dean
Joined: Sun Jun 07, 2009 8:54 am Posts: 65
|
 Sub String in Developer Edition
Hi,
here are my parameters:
PHP, MySQL, Dev Edition, latest version, Custom Code, Update form of table.
Need a substring from field I have entered (e.g. "12:10") My custom code syntax is:
var Arrived = document.getElementById("Sign_In"); ("works fine")
var ArrivedHour = substr(Arrived,0,2); (This code does not get executed).
I spent the whole day figuring out the problem and I pinpointed it to the substr function in the update form. The substr function works fine in the normal Data form (especially in the regular Generator and not the custom code).
Please assist.
Thanks.
|
Sun Jun 07, 2009 9:05 am |
|
 |
commissionxchange
Joined: Fri May 09, 2008 5:38 am Posts: 271 Location: Texas USA
|
 Re: Sub String in Developer Edition
I am not a javascript programmer by any stretch -- that being said looks to me like you are mixing your languages
i.e. part javascript part php
pure javascript would look more like this var ArrivedHour = substring(Arrived,1,2);
note that the 2 is not the length but the last char of the substrong that you want extracted
|
Sun Jun 07, 2009 9:36 am |
|
 |
dean
Joined: Sun Jun 07, 2009 8:54 am Posts: 65
|
 Re: Sub String in Developer Edition
|
Sun Jun 07, 2009 9:38 am |
|
 |
dean
Joined: Sun Jun 07, 2009 8:54 am Posts: 65
|
 Re: Sub String in Developer Edition
To save someone else the same kind of headache, I will post the code which works now perfectly fine:
function Gearbeitet() { //Function Name var Gekommen = document.getElementById("Sign_In").value; //Reads out the time they started var Gegangen = document.getElementById("Sign_Out").value; //Reads out the time they left
var StundenA = Gekommen.substr(0,2); //Reads out the hours (24 hr. military time var StundenL = Gegangen.substr(0,2); //Reads out when they left var Stunden = (StundenL*1 - StundenA*1); //Calculates how many hours they worked (w/o min.)
var MinutenA = Gekommen.substr(3,2); //Reads the Minutes when they came var MinutenL = Gegangen.substr(3,2); //when they left var Minuten = (MinutenA*1 - MinutenL*1); //calculates the minutes to be applied
var Abzug = (Minuten/60).toFixed(2); //bases them on an hour var EStunden = (Stunden*1 - Abzug*1).toFixed(2); //applies the Minutes
document.getElementById("Hours").value = EStunden.toString(); //stores the hours in the HOURS field. THAT'S IT }
|
Sun Jun 07, 2009 11:50 pm |
|
 |
dean
Joined: Sun Jun 07, 2009 8:54 am Posts: 65
|
 Re: Sub String in Developer Edition
|
Sun Jun 07, 2009 11:51 pm |
|
|
|
Page 1 of 1
|
[ 5 posts ] |
|
Who is online |
Users browsing this forum: No registered users and 3 guests |
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot post attachments in this forum
|
|
 |
|