Quantcast
Channel: Adobe Community : Popular Discussions - JavaScript
Viewing all articles
Browse latest Browse all 12130

custom calculations questions

$
0
0

I am working on a time calculation sheet for some employees and i am having some issues.

to start I have the employees starting time say 7:30 am but if they come late it is a deduction which i have working, however if they come in at 7 am then they should get the extra time. and i cant figure out how to do that.  here is the code:

 

var one = this.getField("ClockInM");
var two = this.getField("ClockInOK");


if (one.value >= "8" && one.value <= "22"){
event.value = (".25");
two.value = "";
}
else if (one.value >= "23" && one.value <= "37"){
event.value = (".50");
two.value = "";
}
else if (one.value >= "38" && one.value <= "52"){
event.value = (".75");
two.value = "";
}
else if (one.value >= "53" && one.value <= "67"){
event.value = ("1");
two.value = "";
}
else if (one.value <= "-8" && one.value >= "-22"){
event.value = ("+.25");
two.value = "Yes";
}
else{
event.value = ("");
two.value = "Yes";
}

 

second I have some time calculation JavaScript that is not perfect but works. and Try67 made a comment about making it better and i cant seem to find or remember but he said to do. My multiple sclerosis is reeking havoc on my memory, so please be patient and point me in the right direction.

Here is the JavaScript in question which is all over my form.

var strStart = this.getField("Break1O").value; 
var strEnd = this.getField("Break1I").value; 
strStart = strStart + " 1/1/70"; 
strEnd = strEnd + " 1/1/70";   
if(strStart.length && strEnd.length){   var timeStart = util.scand("h:MM tt m/d/yy", strStart);   var timeEnd = util.scand("h:MM tt m/d/yy", strEnd);   var diff = timeEnd - timeStart;   var oneHour = 60 * 1000;   var timeleft = (diff/oneHour);   if (timeleft > 10){       event.value = 10     }     else     event.value = timeleft     } 
else   event.value = 0 

 

I would upload my document only i cant seem to figure out how to do it. I am a beginner with JavaScript so please be thorough with your suggestions.


Viewing all articles
Browse latest Browse all 12130

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>