Copy link to clipboard
Copied
Hi There!
I have a client who has a fillable form PDF that he uses for a combination work order/invoice. Not the most hi-tech but it works for him and he likes it.
Currently, the working section of the form has 5 sections, each section is its own field:
Part No. / Description / Quantity / Price / Amount
There are 27 rows of these fields. Originally the base form was set up in InDesign and had the rows alternating grey and white (as a static design element)
The quantity and price fields, were set us so that when a value is entered, will calculate and place the product in the Amount field.
The Amount field has a validation script on it already to keep the field blank when nothing is entered. (otherwise, it shows up as $0 on every line)
This is the validation script i used:
if(event.value == 0) event.value = "";
So - here is my challenge:
He wants a change to the form so that this whole section is white, and then where the fields will turn grey when text is entered into it. (on alternating rows still)
I have figured out how to turn these fields grey using a validation script. It works great for the Part No, Description, Quantity & Price fields.
Here is the script that i am using:
color.grey = ["CMYK", 0, 0, 0, 0.3];
var fieldName = "Part*";
if (getField(fieldName).value == "")
{
this.getField(fieldName).fillColor = color.grey;
}
else
{
this.getField(fieldName).fillColor = color.transparent;
}
*with the appropriate field names for the other categories
The problem is when i get to the Amount field. The Amount field already has a validation script in it, and i cannot figure out how to make the two work together.
If i add the 2nd script in below the first one, it makes the Amount field grey all the time. Same thing if i put the first script below the 2nd. I am a novice when it comes to javascript and am not familiar enough with it to know how to adjust for this scenario to make the scripts work together. I tried searching and have found a couple of threads that discuss having 2 validation scripts but they were for specific scenarios and i was unsuccessful applying that info to my own situation.
Ultimately, i need to know how i can have an autocalculation field that stays blank (ie no text value showing, even 0) and also stays white/transparent when there is no total, but then will turn grey when the fields are actually filled.
Any assistance is greatly appreciated. I am using the most recent Acrobat Pro DC on a Mac.
thank you for your time!
THANK YOU Bernd & try67!!! this was very helpful direction and helped me tremendously.
With this info, i was able to determine that i also needed to switch my colors (on that one field only). It's working perfectly now.
Here is what i ended up with code wise:
if(event.value == 0) event.value = "";
color.grey = ["CMYK", 0, 0, 0, 0.3];
var fieldName = "AMT";
if (event.value == "")
{
this.getField(fieldName).fillColor = color.transparent;
}
else
{
this.getFiel
...Copy link to clipboard
Copied
Replace the line
if (getField(fieldName).value == "")
by
if (event.value == "")
Copy link to clipboard
Copied
And simply put the codes one after another, in the same script. Should work fine.
Copy link to clipboard
Copied
THANK YOU Bernd & try67!!! this was very helpful direction and helped me tremendously.
With this info, i was able to determine that i also needed to switch my colors (on that one field only). It's working perfectly now.
Here is what i ended up with code wise:
if(event.value == 0) event.value = "";
color.grey = ["CMYK", 0, 0, 0, 0.3];
var fieldName = "AMT";
if (event.value == "")
{
this.getField(fieldName).fillColor = color.transparent;
}
else
{
this.getField(fieldName).fillColor = color.grey;
}
Thank you again!!