• Global community
• Language:
• Deutsch
• English
• Español
• Français
• Português
• 日本語コミュニティ
Dedicated community for Japanese speakers
• 한국 커뮤니티
Dedicated community for Korean speakers
Exit Search
• Percentage calculations and rounding... HELP!!

# Percentage calculations and rounding... HELP!!

Community Beginner ,
Nov 22, 2022 Nov 22, 2022

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:

• Subtract 47% of the whatever the 'Total Gross' will be
• Round that amount to the nearest dollar

I'm hoping that calculating the 'Net Wages' will just be 'Total Gross - Less Tax (rounded) = ... ?

TIA, I apprecaite any help I can get!

TOPICS
How to , JavaScript , PDF forms

Views

389

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more

Community Expert , Nov 22, 2022 Nov 22, 2022

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

...

8 Replies 8
Community Expert ,
Nov 22, 2022 Nov 22, 2022

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

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Community Beginner ,
Nov 23, 2022 Nov 23, 2022

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).

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Community Expert ,
Nov 23, 2022 Nov 23, 2022

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;

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Community Beginner ,
Nov 23, 2022 Nov 23, 2022

Copied

I'm assuming I will have to amend the 'net wages' field now too?

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Community Expert ,
Nov 23, 2022 Nov 23, 2022

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.

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Community Beginner ,
Nov 23, 2022 Nov 23, 2022

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.

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Community Expert ,
Nov 23, 2022 Nov 23, 2022

Copied

Select 'Prepare form' tool, then click on 'More' then click 'Set field calculation order', make sure tax field is above 'net wages' field.

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Community Beginner ,
Nov 23, 2022 Nov 23, 2022

Copied

LATEST

Thank you so much!