• Global community
• Language:
• Deutsch
• English
• Español
• Français
• Português
• 日本語コミュニティ
Dedicated community for Japanese speakers
• 한국 커뮤니티
Dedicated community for Korean speakers
Exit
• Calculate based on the value of another field and ...

# Calculate based on the value of another field and leave blank if other field is blank

Explorer ,
Jul 22, 2024 Jul 22, 2024

Copied

I am looking for some help with form field calculations .

1. I need to multiply "TGAI" * 0.03 , but if  "MedicalExpenses" is empty then leave return the value of "0".

•  this field, when calculated needs to return a negative value

2. If  "HPW" AND "WPY" are blank then leave cell blank if "HPW" AND "WPY" have values then multiply "HW" * "HPY"

TOPICS
How to , JavaScript , PDF , PDF forms

Views

249

Report

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

Enthusiast , Jul 23, 2024 Jul 23, 2024

A couple of issues:

1)  You had a validation script AND a calculation script in the field.  Remove the validation script.

2)  You missed the ! in my script, which changes the statement to a value vs no value.  Here's the calculation script again (copy and paste it).

if(!this.getField("MedicalDeduction").value)
{event.value=0}
else
{event.value=this.getField("Calc_TotalGAI").value * .03 * -1}

Enthusiast , Jul 23, 2024 Jul 23, 2024

if(!this.getField("GMI.0").value)
{event.value=25}
else
{event.value=this.getField("Calc_TotalMonthlyPayment").value-this.getField("Utilities").value}

10 Replies 10
Enthusiast ,
Jul 22, 2024 Jul 22, 2024

Copied

1.

if(!this.getField("MedicalExpense").value)

{event.value=0}

else

{event.value=this.getField("TGAI").value * .03 * -1}

2.

if(this.getField("HPW").value && this.getField("WPY").value)

{event.value=this.getField("HPW").value * this.getField("WPY").value}

else

{event.value=""}

Report

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

Copied

Good morning and thank you for your response . the script provided for #1 does not work , but #2 does .

Report

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

Copied

What result are you getting.  Do you have errors in the console?

Report

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

Copied

Thats the odd thing, im not getting any error messages , its just not calculating .

Report

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

Copied

Report

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

Copied

Yes , it may look a little off as i had to scrub some of the information from the document . I left notes on the bottom in regard to the issue .

Report

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

Copied

A couple of issues:

1)  You had a validation script AND a calculation script in the field.  Remove the validation script.

2)  You missed the ! in my script, which changes the statement to a value vs no value.  Here's the calculation script again (copy and paste it).

if(!this.getField("MedicalDeduction").value)
{event.value=0}
else
{event.value=this.getField("Calc_TotalGAI").value * .03 * -1}

Report

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

Copied

That worked , thank you so much , now i just have one more issue on this form and im done with it .

if you dont mind taking a look when you get a chance i would really appriciate it .

I have left notes on the form and included the entire worksheet this time for your reference .

Again , thank you for your time

Report

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

Copied

if(!this.getField("GMI.0").value)
{event.value=25}
else
{event.value=this.getField("Calc_TotalMonthlyPayment").value-this.getField("Utilities").value}

Report

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

Copied

LATEST

Thank you so much for your help !