Have two separate fields with script that I want as one

New Here ,
Jul 14, 2017

Copy link to clipboard

Copied

Hello, I'm new to JavaScript for Adobe forms I'm not sure of all the coding or proper terminology. So far I've been doing alright searching the forums for answers, but I can't seem to get this one right.

I have two separate fields with script in them that when the boxes are checked it calculates the savings for the customer. One is for how much they would have saved if they where members and the other is how much they are saving because they are members. It's 20% difference for members and none members.

I would like to put all of the script into one field to run the calculations. When I try to combine them only one check box will work the other doesn't.

The two fields and scripts are

SmileyClubSavings

if (this.getField("RepairFee").isBoxChecked(0)=="1"){event.value=this.getField("Price").value*0.2;} else event.value = 0;

Subtract

if (this.getField("SmileyClubDiscount").isBoxChecked(0)=="1"){event.value=this.getField("SmileyClub").value-this.getField("Price").value;} else event.value = 0;

Working with Adobe Acrobat Pro DC

TOPICS
Acrobat SDK and JavaScript, Windows

Views

121

Likes

Translate

Translate

Report

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

Have two separate fields with script that I want as one

New Here ,
Jul 14, 2017

Copy link to clipboard

Copied

Hello, I'm new to JavaScript for Adobe forms I'm not sure of all the coding or proper terminology. So far I've been doing alright searching the forums for answers, but I can't seem to get this one right.

I have two separate fields with script in them that when the boxes are checked it calculates the savings for the customer. One is for how much they would have saved if they where members and the other is how much they are saving because they are members. It's 20% difference for members and none members.

I would like to put all of the script into one field to run the calculations. When I try to combine them only one check box will work the other doesn't.

The two fields and scripts are

SmileyClubSavings

if (this.getField("RepairFee").isBoxChecked(0)=="1"){event.value=this.getField("Price").value*0.2;} else event.value = 0;

Subtract

if (this.getField("SmileyClubDiscount").isBoxChecked(0)=="1"){event.value=this.getField("SmileyClub").value-this.getField("Price").value;} else event.value = 0;

Working with Adobe Acrobat Pro DC

TOPICS
Acrobat SDK and JavaScript, Windows

Views

122

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Jul 14, 2017 0
Adobe Community Professional ,
Jul 15, 2017

Copy link to clipboard

Copied

What happens when both boxes are checked?

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Jul 15, 2017 0
New Here ,
Jul 17, 2017

Copy link to clipboard

Copied

Sorry for delay in responding. I'm part time and work every other day.

When both boxes are checked they still calculate an answer. One is for 20% off original price and the other calculates 80% back to the discounted price. But only one box will be checked at a time. I'm just trying to put both final calculations into one field. Right now I have one field on top of the other.

If I put the code for SmileyClubSavings and Subtract in the Custom calculation script field only the the code for Subtract works. I'm not sure of how to join the two.

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Jul 17, 2017 0