Copy link to clipboard
Copied
Okay, hopefully the last question of the day...
I've simplified my problem down to the following: I have two radio buttons that, when clicked, populate a combobox with a set of options. The first set consists of the numbers 1-5, and the second is simply the string "N/A". Then down below, a numeric Cost field will check to see if the contents of the Quantity field is not "N/A", and if it's not, it will turn the quantity string into an integer and multiply it by 10. Otherwise, if it is "N/A", it will return 0.
The problem is that, as soon as you click on either radio button, Acrobat gives the error "The value entered does not match the format of the field [ Cost ]". So it sounds like Cost is expecting an integer and receiving a string, but I'm not sure why it would be getting a string. Other than that, it works as expected.
Use this code for the Cost field:
var qty = this.getField("Quantity").valueAsString;
if (qty != "N/A") {
event.value = Number(qty) * 10;
} else {
event.value = 0;
}
Copy link to clipboard
Copied
Why is the Quantity field a drop-down if it has a calculated value? It would make more sense to use a text field.
Try changing the format of the Cost field to None and see what the results are.
If you can't get it to work please share the file with us.
Copy link to clipboard
Copied
Changing the format of Cost to none does indeed eliminate the error. But I would really like the result to be formatted as a dollar amount, since that's the way the other fields on the page are formatted.
The Quantity field is a drop-down because I want the user to be able to select from a limited set of quantities. A text field would allow them to enter any quantity. The available quantities change based on what option they select.
Copy link to clipboard
Copied
You can download the PDF here.
Copy link to clipboard
Copied
Use this code for the Cost field:
var qty = this.getField("Quantity").valueAsString;
if (qty != "N/A") {
event.value = Number(qty) * 10;
} else {
event.value = 0;
}
Copy link to clipboard
Copied
Perfect. Thank you so much. You've helped me a lot today!
Find more inspiration, events, and resources on the new Adobe Community
Explore Now