Skip to main content
Inspiring
February 26, 2017
Question

If else statement. What am I doing wrong here?

  • February 26, 2017
  • 2 replies
  • 576 views

I have a list box, Tuition, with three available values, 0 (default), 1649, and 1872. In another field (FICA), I want to create a conditional calculation based on the result of what is selected in Tuition. The purpose is to determine if an amount is taxable based on the result of a calculation. But, I can't even get past square 1, determining which item User has selected!

This is not the entire script that will eventually be in FICA. I'm just trying to diagnose my problem.

The following code was copied from a tutorial.

var nTuition = this.getField("Tuition").value;

if( nTuition = 1649) event.value = 1649;

else event.value = 1872;

When executed, the above will only return 1649, regardless of what is selected in Tuition. I have Tuition execute the calculation immediately. And, the FICA field is top in the calculation order. 1649 appears in FICA, even after resetting all fields (should be 0). It would seem, given the above code, that the default Tuition value of 0 would return 1872, no?

What is going on here???

Thanks!

This topic has been closed for replies.

2 replies

rsbisaAuthor
Inspiring
February 26, 2017

Well, that was easy (said after 3 hours of toil).

Works perfectly. Thank you!

try67
Community Expert
Community Expert
February 26, 2017

The comparison operator in JS is "==", not "=". That's the assignment

operator.