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

Participant ,
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, PDF forms

Views

387

Likes

translate

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

Copy link to clipboard

Copied

To access field values you must use:

this.getField(" field name ").value

Likes

translate

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
Participant ,
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?

Likes

translate

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

Copy link to clipboard

Copied

Likes

translate

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
Participant ,
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

Likes

translate

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

Likes

translate

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
Most Valuable Participant ,
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);
}

Likes

translate

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

Copy link to clipboard

Copied

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

Likes

translate

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