Copy link to clipboard
Copied
Hi everyone,
"IF(Field8>Calculated Field; text color RED;text color Black)"
here it will be a bonus for me if I will know how to change and backround of a field on whish, not only the text, but anyway, dont count how small hint I will receive, it will be more than I have now.
Thanks in advance for your time and efforts,
Cristian
- It should go under the latter, Custom Calculation Script.
- I made a small mistake in the code. It's fixed now.
Change:
v3=<5
To:
v3<=5
Copy link to clipboard
Copied
For 1:
var v1 = Number(this.getField("Field1").valueAsString);
var v2 = Number(this.getField("Field2").valueAsString);
var v3 = Number(this.getField("Field3").valueAsString);
var v4 = Number(this.getField("Field4").valueAsString);
var v5 = Number(this.getField("Field5").valueAsString);
var v6 = Number(this.getField("Field6").valueAsString);
var v7 = Number(this.getField("Field7").valueAsString);
event.value = v1*v2+(v3<=5 ? v4 : v5)*v6+v7;
For 2:
var v8 = Number(this.getField("Field8").valueAsString);
if (v8>event.value) {
event.target.textColor = color.red;
event.target.fillColor = color.black;
} else {
event.target.textColor = color.black;
event.target.fillColor = color.red;
}
PS. I moved your question to the Acrobat forum from the Reader forum.
Edit: mistake in code fixed
Copy link to clipboard
Copied
Thank you very much for you answer, seems somehow easy....until I tried to put it into practice.
So, regarding first point, when I have tried to insert the script(adapted after my needs) in
"Simplified field notation" - is accepted, but no any generated value.
when I try to insert in "Custom calculation script", I receive next error and cannot pass over.
Clear, I missed the correct point or position to use, or form to introduct.
Moreover, I have 4 different Fields which need this Calculated Value in base of 4 different situation, then, I suppose is necessary and a clear definition of "event.value" for each of those 4 Fields, not only for first of them.
All those 4 Fields are like "Calculated Value" for each standard situation on which is reffering and have no connection with....
now I will refer on second point, about text/background color, where that task should occur when the value manually inserted in that field is over "Calculated value" for this specific Field, not the one on top. So, if I try to estimate how should be(with your script and my supposing) is like this:
var v1 = Number(this.getField("Case1").valueAsString);\\variabil, 1 for each 4 cases in a row
var v2 = Number(this.getField("Length").valueAsString);\\ fixed for all 4 cases in a row(96)
var v3 = Number(this.getField("-5").valueAsString);\\ fixed field for all
var v4 = Number(this.getField("+5").valueAsString);\\ fixed field for all
var v5 = Number(this.getField("Splice").valueAsString);\\ fixed for all 4 cases in a row(96)
var v6 = Number(this.getField("Field6").valueAsString);\\ fixed field for all
var v7 = event.value = v1*v2+(v2=<5 ? v3 : v4)*v5+v6*2;\\ 1 for each 4 cases in a row
\\ this means v7 is different on each Field from all 4*96 rows, IF value manually inserted in this field is > respective "Calculated Value" according his case THEN
var v8 = Number(this.getField("This Field").valueAsString);
if (v8>event.value) {
event.target.textColor = color.red;
event.target.fillColor = color.black;
} else {
event.target.textColor = color.black;
event.target.fillColor = color.red;
}
Clear, my pro point is not explaining in words, but maybe another visual try can be more helpfull to understand correct the needs.
So, simple:
- first point is refering only on 4 Fields which are calculated in fct of specific Fields(in red marked) , just for consulting the accepted limits, which can be changed without any influence in down part.
- second point is refering on blue marked area(where can be visible some values writen with red), those values being compared with his own calculation according same formula as point 1, but in function of his own Length and Splice(different from row to row)
In Excel was somehow easy to obtain the desired result, but with under 48h experience in Acrobat Pro and Java seems not so fast for me. I hope I was enough clear in my tentative to explain the problem, and I would like to thank you again for your time spend with this topic.
best regards,
Copy link to clipboard
Copied
- It should go under the latter, Custom Calculation Script.
- I made a small mistake in the code. It's fixed now.
Change:
v3=<5
To:
v3<=5
Copy link to clipboard
Copied
This change works like a charm, and I have achieved and for second point to compile things for obtaining desired result. Thanks again many many times!