It is currently Sun Dec 16, 2018 7:35 pm




Post new topic Reply to topic  [ 5 posts ] 
Sub String in Developer Edition 
Author Message

Joined: Sun Jun 07, 2009 8:54 am
Posts: 65
Post 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
Profile E-mail

Joined: Fri May 09, 2008 5:38 am
Posts: 271
Location: Texas USA
Post 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
Profile E-mail YIM WWW

Joined: Sun Jun 07, 2009 8:54 am
Posts: 65
Post Re: Sub String in Developer Edition
You are right. I just realized that.

Thanks a Million. You saved my day! :lol: :lol: :lol: :lol: :lol: :lol: :lol: :lol: :lol: :lol: :lol:


Sun Jun 07, 2009 9:38 am
Profile E-mail

Joined: Sun Jun 07, 2009 8:54 am
Posts: 65
Post 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
Profile E-mail

Joined: Sun Jun 07, 2009 8:54 am
Posts: 65
Post Re: Sub String in Developer Edition
P.S. And yes, I have mixed the PHP syntax with the Javascript syntax, and that was 100% my error.

:shock: :shock: :shock:


Sun Jun 07, 2009 11:51 pm
Profile E-mail
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 5 posts ] 


Who is online

Users browsing this forum: No registered users and 1 guest


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

Jump to:  
cron
Copyright © 2004-2008 TheDevShop Ltd. All Rights Reserved