Copy link to clipboard
Copied
Hi,
I wouldn't even call myself a beginner with Adobe and JavaScript... Hence why I have turned to the brains trust for help, please!
I've figured out how to calculate 'Total Gross' (PER DAYRow1 + PER DAYRow2 etc...).
I now need the form to:
I'm hoping that calculating the 'Net Wages' will just be 'Total Gross - Less Tax (rounded) = ... ?
TIA, I apprecaite any help I can get!
You don't need script for this, you can use 'Simplified Field Notation' instead.
If you want to round value to whole number, format "LESS TAX" field as number with 0 decimals and since you have space character in field names you need to escape space character with backslash, write exactly like this in simplified field notations:
In "LESS TAX" field under simplified field notation, use this:
0.47*TOTAL\ GROSS
In "NET WAGES" field under simplified field notation, use this:
TOTAL\ GROSS-LESS\ TAX
...Copy link to clipboard
Copied
You don't need script for this, you can use 'Simplified Field Notation' instead.
If you want to round value to whole number, format "LESS TAX" field as number with 0 decimals and since you have space character in field names you need to escape space character with backslash, write exactly like this in simplified field notations:
In "LESS TAX" field under simplified field notation, use this:
0.47*TOTAL\ GROSS
In "NET WAGES" field under simplified field notation, use this:
TOTAL\ GROSS-LESS\ TAX
Copy link to clipboard
Copied
Thanks so much Nesa, you're my new best friend!
When the net wages field calculates, is there a trick so that it calculates the less tax field as a whole dollar amount - at the moment it's calculating as a decimal figure (even though I've changed the format to 0 decimals).
Copy link to clipboard
Copied
Sorry, I thought you just want to show rounded number, format only show whole number while value remains the same.
In tax field, use this as custom calculation script:
var TG = Number(this.getField("TOTAL GROSS").valueAsString);
if(TG){
var total = Math.round(0.47*TG);
event.value = total;}
else
event.value = 0;
Copy link to clipboard
Copied
Perfect, thank you for your prompt reply.
I'm assuming I will have to amend the 'net wages' field now too?
Copy link to clipboard
Copied
You can leave 'net wages' field as it is, although you will have to change field calculation order, let me know if you don't know how to do that.
Also, you can remove format from 'tax' field.
Copy link to clipboard
Copied
I have no idea how to change field calculation order, sorry - are you able to show/tell me how?
Thank you so much for all your help, it's extremely apprecaited.
Copy link to clipboard
Copied
Select 'Prepare form' tool, then click on 'More' then click 'Set field calculation order', make sure tax field is above 'net wages' field.
Copy link to clipboard
Copied
Thank you so much!