javascript not working for time calculation
i making trip sheet form , have code calcualte time not working. need please! post script below
function hhmm2num(cformat, ctime) {
var cdate = "1-jan-1970 " + ctime;
var odate = util.scand("dd-mmm-yyyy " + cformat, cdate);
var ndate = odate.gettime();
( 1000 milliseconds in second, 60 seconds in minute)
return math.floor(ndate / (1000 * 60));
}
function num2hmm(nmin) {
var nhrs = math.floor(nmin / 60);
var nmins = nmin % 60;
return util.printf("%,201.0f:%,202.0f", math.floor(nmin / 60), nmin % 60);
}
var cmeetingsin = this.getfield("meetingsin").value;
var cmeetingsout = this.getfield("meetingsout").value;
var cloadin = this.getfield("loadin").value;
var cloadout = this.getfield("loadout").value;
var ctraveltoin = this.getfield("traveltoin").value;
var ctraveltoout = this.getfield("traveltoout").value;
var csitein = this.getfield("sitein").value;
var csiteout = this.getfield("siteout").value;
var ctravelfromin = this.getfield("travelfromin").value;
var ctravelfromout = this.getfield("travelfromout").value;
var cunloadout = this.getfield("unloadout").value;
var cofficein = this.getfield("officein").value;
var cofficeout = this.getfield("officeout").value;
var cofficeinone = this.getfield("officeinone").value;
var cofficeoutone = this.getfield("officeoutone").value;
var cofficeintwo = this.getfield("officeintwo").value;
var cofficeouttwo = this.getfield("officeouttwo").value;
var cofficeinthree = this.getfield("officeinthree").value;
var cofficeoutthree = this.getfield("officeoutthree").value;
event.value = "";
if(cmeetingsin != "" && cmeetingsout != "" && cloadin !="" && cloadout !="" && ctraveltoin !="" && ctraveltoout !="" && csitein !="" && csiteout !="" && ctravelfromin !="" && ctravelfromout !="" && cunloadout !="" && cofficein !="" && cofficeout !="" && cofficeinone !="" && cofficeoutone !="" && cofficeintwo !="" && cofficeouttwo !="" && cofficeinthree !="" && cofficeoutthree !="") {
// convert time strings minutes using hhmm2num function
var nmeetingsin = hhmm2num("h:mm tt", cmeetingsin);
var nmeetingsout = hhmm2num("h:mm tt", cmeetingsout);
var nloadin = hhmm2num("h:mm tt", cloadin);
var nloadout = hhmm2num("h:mm tt", cloadout);
var ntraveltoin = hhmm2num("h:mm tt", ctraveltoin);
var ntraveltoout = hhmm2num("h:mm tt", ctraveltoout);
var nsitein = hhmm2num("h:mm tt", csitein);
var nsiteout = hhmm2num("h:mm tt", csiteout);
var ntravelfromin = hhmm2num("h:mm tt", ctravelfromin);
var ntravelfromout = hhmm2num("h:mm tt", ctravelfromout);
var nunloadout = hhmm2num("h:mm tt", cunloadout);
var nofficein = hhmm2num("h:mm tt", cofficein);
var nofficeout = hhmm2num("h:mm tt", cofficeout);
var nofficeinone = hhmm2num("h:mm tt", cofficeinone);
var nofficeoutone = hhmm2num("h:mm tt", cofficeoutone);
var nofficeintwo = hhmm2num("h:mm tt", cofficeintwo);
var nofficeouttwo = hhmm2num("h:mm tt", cofficeouttwo);
var nofficeinthree = hhmm2num("h:mm tt", cofficeinthree);
var nofficeoutthree = hhmm2num("h:mm tt", cofficeoutthree);
var ndiff = nmeetingsin - nmeetingout + nloadin - nloadout + ntraveltoin - ntraveltoout + nsitein - nsiteout + ntravelfromin - ntravelfromout + ntravelfromout - nunloadout + nofficein - nofficeout + nofficeinone - nofficeoutone + nofficeintwo - nofficeouttwo + nofficeinthree - nofficeoutthree;
ndiff -= this.getfield("lunch").value;
event.value = num2hmm(ndiff);
i have little interest in reading on long swathes of script try desperately figure out supposed , why doesn't work. it's incomplete.
what mean "not working"? expect happen, , happens instead? messages, if any, in javascript console?
what type of event/action script connected to?
More discussions in PDF Forms
adobe
Comments
Post a Comment