Skip to main content
Jackw77
Participant
January 21, 2020
Question

'If' statement on form syntax error

  • January 21, 2020
  • 1 reply
  • 220 views

Hi guys,

 

I'm trying to write code for an 'if' statement on a form but I'm getting a syntax error and can't work out why. It's saying the error is on line 2... I'm new to this! Please help.

 

Basically I need the average of variable A and variable B calculating, but only if variable B is greater than variable A. If variable B is greater than variable A, use B. This is the code:

 

var A = this.getField("<Actual>").value + var B = this.getField("<Google Maps>").value /2;
if( B > A ) event.value = B;
else event.value = this.getField("<Value>").value;

 

This topic has been closed for replies.

1 reply

try67
Community Expert
Community Expert
January 21, 2020

Change this line:

var A = this.getField("<Actual>").value + var B = this.getField("<Google Maps>").value /2;

To:

var A = this.getField("<Actual>").value;

var B = this.getField("<Google Maps>").value/2;