Copy link to clipboard
Copied
I am trying to get rid of NaN being dsiplayed.
event.value = this.getField("End Time Day One").value - this.getField("Start Time Day One").value;
if (isNaN(event.value) || event.value == 0) {
event.value = "";
}
var total = this.getField("Total Hours Day One").value;
if (this.getField("Check Box 1").value != "Off") {
event.value = Number("Total Hours Day One") - 1;
} else {
event.value = Number("Total Hours Day One");
}
Copy link to clipboard
Copied
To access a field's value you must use getField("...").value, not just specify the field's name... You did it correctly in the first line of code, but not later on. Also, the second part of your code overrides the first one. You should put all the second part inside an "else" clause.
Copy link to clipboard
Copied
So I am extremely new at this. I am not sure where I stopped using getField. Can you eloborate?
Thank you
Copy link to clipboard
Copied
Number("Total Hours Day One")
Copy link to clipboard
Copied
I do not understand. Sorry
Copy link to clipboard
Copied
Number("Total Hours Day One") should be Number(this.getField("Total Hours Day One").value) or, since you defined the value as total: Number(total)
Copy link to clipboard
Copied
Thank you
Copy link to clipboard
Copied
Hi @brantpro1 ,
There were a few things with the original work that still wasn't working right.
I've attached the form (linked below) with some improvements.
Copy link to clipboard
Copied
Hello,
Thank you for the improvements. Where are the calculations and javascript. When I prepare a form and look at the properties, I see no calculations or javascript to excute the function.
Copy link to clipboard
Copied
Copy link to clipboard
Copied
Thank you
Copy link to clipboard
Copied
Sorry again... I meant to say that the Total Hours Day One, Total Hours Day Two, and the Total Hours Day Three fields have their own custom calculation script.
Here's the link to the updated PDF file:
See example scripts below:
Custom calculation script for Total Hours Day One
var name = this.getField("Name").value;
var day1 = this.getField("Day One").value
var startDay1 = this.getField("Start Time Day One").value;
var endDay1 = this.getField("End Time Day One").value;
var workHours1 = Number(endDay1) - Number(startDay1);
var checkBX1 = getField("Check Box 1");
if (name !=="" && day1 !=="" && (startDay1 !== "- Start Time -" && endDay1 !== "- End Time -")) {
(checkBX1.value != "Off" ) ? event.value = workHours1 -1 : event.value = workHours1;
} else {
event.value =""
}
Custom calculation script for Total Hours Day Two
var name = this.getField("Name").value;
var day2 = this.getField("Day Two").value
var startDay2 = this.getField("Start Time Day Two").value;
var endDay2 = this.getField("End Time Day Two").value;
var workHours2 = Number(endDay2) - Number(startDay2);
var checkBX2 = getField("Check Box 2");
if (name !=="" && day2 !=="" && (startDay2 !== "- Start Time -" && endDay2 !== "- End Time -")) {
(checkBX2.value != "Off" ) ? event.value = workHours2 -1 : event.value = workHours2;
} else {
event.value =""
}
Custom calculation script for Total Hours Day Three
var name = this.getField("Name").value;
var day3 = this.getField("Day Three").value
var startDay3 = this.getField("Start Time Day Three").value;
var endDay3 = this.getField("End Time Day Three").value;
var workHours3 = Number(endDay3) - Number(startDay3);
var checkBX3 = getField("Check Box 3");
if (name !=="" && day3 !=="" && (startDay3 !== "- Start Time -" && endDay3 !== "- End Time -")) {
(checkBX3.value != "Off" ) ? event.value = workHours3 -1 : event.value = workHours3;
} else {
event.value =""
}
Copy link to clipboard
Copied
Not a good idea to upload a form with a list of people and corresponding PINs.
Copy link to clipboard
Copied
Appreciate the advice. I figured this wasa a safe community.
Find more inspiration, events, and resources on the new Adobe Community
Explore Now