What do you mean by "does not work"? Do you get an error, or just the wrong
result? If the latter, which result are you getting?
Apologies for being vague..!
What the script is doing is returning a value based on £100 initial cost then applying a 10% discount as -£900.
When I need it (or another script) to return -£10.
Sorry for any confusion.
What's the actual value of both fields? Is the percentage actually 10, or is
it 0.1 (as Acrobat usually treats percentage fields)?
You can check by adding this to your script (after the first two lines):
app.alert("Weekly Amount is: " + a.value);
app.alert("Package Discount is: " + b.value);
Also, you can post the file to the forum.
Yes the percentage field shows as 10% and the value of the Weekly Amount field is £100.
I am unable to post the form, sorry.
So the discount is -1 * a * (b/100)
So would the revised script look like this;
var a = this.getField("Weekly Amount");
var b = this.getField("Package Discount");
event.value = a.value - (-1 * a.value * (b.value/100));
If so that does not calculate the discount as I need it to.!
There must be something wrong with the value of the fields.
I can't help you anymore if you don't post more info or the file.
If the discount field is formatted as a percentage, you do not need to divide it by 100 as the value entered into the percentage field is a decimal value and then for the display the value is multiplied by 100, but the calculation value is still the decimal number.
var a = this.getField("Weekly Amount").value;
var b = this.getField("Package Discount").value;
var discount = a * b;
event.value = a- discount;