Javascript help!!!

Community Beginner ,
Jun 10, 2022 Jun 10, 2022

Copy link to clipboard

Copied

I am trying to copy the numeric value of one field to another numeric field, based upon the Yes/No drop-down field. I keep geting a syntax error on the assign line of code.

var amt1 = this.getField("Amount_1");

var answer = this.getField("Dropdown");

var amt2 = this.getField("Amount_2");

//If Dropdown is Yes, copy //amt1 to amt2. Otherwise, //goto amt2 field and enter //a different amount.
If (answer.value == "Yes"){
var amt2.value = amt1;
}

TOPICS
JavaScript

Views

60

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
community guidelines
Adobe Community Professional ,
Jun 10, 2022 Jun 10, 2022

Copy link to clipboard

Copied

Use this:

if (answer.value == "Yes"){ amt2.value = amt1.value; }

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
community guidelines
Community Beginner ,
Jun 10, 2022 Jun 10, 2022

Copy link to clipboard

Copied

Even with your changes I was getting a syntax error. The I realized I was capitalizing the "I" in if - typing habits.

It worked, thanks. But I want to put either a space or the number 0 if select no. I made the change but getting a syntax. Here is the "if" statement.

if(answer.value == "Yes"){
amt2.value = amt1.value;
else
amt2.value = 0;
//amt2.value = " ";
}

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
community guidelines
Adobe Community Professional ,
Jun 10, 2022 Jun 10, 2022

Copy link to clipboard

Copied

Remove { and }

or use:

if(answer.value == "Yes"){
amt2.value = amt1.value;
} else {
amt2.value = 0;
//amt2.value = " ";
}

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
community guidelines
Community Beginner ,
Jun 11, 2022 Jun 11, 2022

Copy link to clipboard

Copied

Thank you for following up. I had forgotten the proper use of the {}. It's been a few years.

It works but have a different issue. The timing of updating other field amounts using simplified field notations are off. I put in amounts that should total but lag behind. It maybe a couple of fields later that these do update. It started when I encorporated the Javascript. Do you know how Acrobat processes its fields on a form? Is their a field heirarchy? If, so can you change or manipulate it?  Thanks again for your directions.

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
community guidelines
Adobe Community Professional ,
Jun 11, 2022 Jun 11, 2022

Copy link to clipboard

Copied

Change the field calculation order.

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
community guidelines
Community Beginner ,
Jun 13, 2022 Jun 13, 2022

Copy link to clipboard

Copied

LATEST

Thank you. I'm having a hard time to locate a book that covers the advanced features of Acrobat DC Pro. Do you have any recommendations?

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
community guidelines