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

Using a conditional statement to compute and assign a value to a field

Community Beginner ,
Oct 13, 2016 Oct 13, 2016

I have no idea how to start it out but what I need to accomplish is when distance is greater than 50 then fee is equal to (((distance * 2) - 100) * 0.55) otherwise if distance is equal to or less than 50, then fee is 0.  How do I accomplish this in a Javascript calculation?

I've tried this

var d = Number(this.getField("Distance").value);

if (d > 50) event.value = (((d * 2) - 100) * .55);

if (d == 50) event.value = "0";

if (d < 50) event.value = "0"

TOPICS
Acrobat SDK and JavaScript , Windows
499
Translate
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

LEGEND , Oct 13, 2016 Oct 13, 2016

Try this:

if (d > 50) {

    event.value = (d * 2 - 100) * .55;

} else {

    event.value = 0;

}

Translate
LEGEND ,
Oct 13, 2016 Oct 13, 2016

Try this:

if (d > 50) {

    event.value = (d * 2 - 100) * .55;

} else {

    event.value = 0;

}

Translate
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 ,
Oct 14, 2016 Oct 14, 2016
LATEST

Thank you, again.  I'll try this out, too.

Translate
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