Copy link to clipboard
Copied
Hello,
I am having an issue with percent text fields double/triple/quadruple/etc calculating when I use a custom script to divide the field by 100 or multiply by .01 to stop the automatic "multiply value by 100"
I am able to make the first field calculation work (I'll call that "FieldA"), so that when I enter "1" it converts it to 1.00% not 100%. But when I do the same calculation in the next percent text field (I'll call that "FieldB"), it will calculate it correctly, but will multiply "FieldA" again to the value 0.01%
When I have a third field (I'll call that "FieldC") it will work for "FieldC" but it will calculate "FieldB" again to .01 & "FieldA" again to .0001
I am using... event.value = this.getField("FieldA").value*.01 for FieldA event.value = this.getField("FieldB").value*.01 for FieldB & event.value = this.getField("FieldC").value*.01 for Field C
Hopefully that makes sense. Thank you!!
Copy link to clipboard
Copied
So, you're fighting the field formatting. Not a good idea. I would suggest removing the formatting entirely and then figure out how you want the calculations to work. The number scheme need to be consistent all the way though.
So the formatting only affects how the number is displayed to the user, not the actual value. Once you figure out the calculations, then you can create a custom format script that will work for how you want the value displayed to the user.
Copy link to clipboard
Copied
Okay, so if I want the field to display 75.00% when the user enters 75 into the field. How would I do that? Is that possible?
Copy link to clipboard
Copied
Yes, nearly any format you can think of is possible, but anthing that is non-standard requires a script
Enter this into the Custom format script for the field:
event.value = util.printf("%0.2f%",event.value);
Copy link to clipboard
Copied
Hi Thom,
I entered that script for the first text field. I entered 1.5 and it converted it to 1.50%. When I entered 1.5 into the 2nd text field, it converted it to 1.50% but automattically changed the first field box to 1.#R%. When I enter 1.5 into the third text field, it converts to 1.50% but changes text field 2 also to 1.#R%
Copy link to clipboard
Copied
Does you use any calculation at the fields?
Copy link to clipboard
Copied
I do not believe so. I put "Format" to "None"
And under the "Calculate" tab - I selected "Custom Calculation Script" and put the above script you told me to use.
Copy link to clipboard
Copied
Why does you use the script there?
Copy link to clipboard
Copied
Oh, so I go under the "Format" tab and put it under the "Custom Format Script" ?
Copy link to clipboard
Copied
Also, when I put that script only into one text field, it will work. But as soon as I enter anything into any other field. Even if I type a letter into a text field, it will change the field with the script to "1.#R%"
Copy link to clipboard
Copied
The script I provided must be placed in the custom format script. If used in the format script, and no where else, then it is impossible for it to affect any other field.
You see, the format script only affects the appearance of the field, not anything else. So if the other fields are being affected, then the script is not in the custom format. Please ensure that is only in the custom format.
Also, the "1.#R%" output is caused by the value of the field not being a number. This script can only be used to format numbers, nothing else.
Find more inspiration, events, and resources on the new Adobe Community
Explore Now