Skip to main content
Participant
October 14, 2016
Answered

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

  • October 14, 2016
  • 1 reply
  • 563 views

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"

This topic has been closed for replies.
Correct answer George_Johnson

Try this:

if (d > 50) {

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

} else {

    event.value = 0;

}

1 reply

George_JohnsonCorrect answer
Inspiring
October 14, 2016

Try this:

if (d > 50) {

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

} else {

    event.value = 0;

}

Participant
October 14, 2016

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