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

Another if/else query - help needed again please *solved*

Contributor ,
Oct 18, 2019 Oct 18, 2019

Copy link to clipboard

Copied

I'm missing something again as this isn't working either 😞

The first part - if "vat rate.10" says Exempt then "vat value.10" will show 0 - works great, but I can't get the next bit to work. If "vat rate.10" contains a value (any percentage), then "vat value.10" should show "aVATRate.10 x "net value.10"

 

 

if (this.getField("vat rate.10").value == "Exempt") {
event.value = 0;
}
else {"aVATRate.10"*"net value.10";
}

TOPICS
Acrobat SDK and JavaScript

Views

602

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

correct answers 1 Correct answer

Community Expert , Oct 20, 2019 Oct 20, 2019

Use this code:

 

if (this.getField("vat rate.10").value == "Exempt") {
	event.value = 0;
} else {
	event.value = Number(this.getField("aVATRate.10").valueAsString) * Number(this.getField("net value.10").valueAsString);
}

Votes

Translate

Translate
Community Expert ,
Oct 18, 2019 Oct 18, 2019

Copy link to clipboard

Copied

To access field values you must use:

this.getField(" field name ").value

Votes

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
Contributor ,
Oct 18, 2019 Oct 18, 2019

Copy link to clipboard

Copied

So where would that bit go in my poor attempt in the original question?

Votes

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 Expert ,
Oct 18, 2019 Oct 18, 2019

Copy link to clipboard

Copied

Votes

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
Contributor ,
Oct 18, 2019 Oct 18, 2019

Copy link to clipboard

Copied

I tried following the earlier one:

 

if (this.getField("vat rate.10").value == "Exempt") {
event.value = 0;
}
else {
event.value = this.getField("vat rate.10").value = "aVATRate.10" * "net value.10";
}

but the following appears

clipboard_image_0.png

Vat value.10 is formated as a number with 2 decimal places

Votes

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 Expert ,
Oct 20, 2019 Oct 20, 2019

Copy link to clipboard

Copied

Hi,

 

Check the field properties , under the Format tab for the  "vat rate.10"  field , it should be set to none. 

Votes

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 Expert ,
Oct 20, 2019 Oct 20, 2019

Copy link to clipboard

Copied

Use this code:

 

if (this.getField("vat rate.10").value == "Exempt") {
	event.value = 0;
} else {
	event.value = Number(this.getField("aVATRate.10").valueAsString) * Number(this.getField("net value.10").valueAsString);
}

Votes

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
Contributor ,
Oct 20, 2019 Oct 20, 2019

Copy link to clipboard

Copied

LATEST

Perfect!!!! Thank you Try 67, much appreicated 🙂

Votes

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