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

'If' statement on form syntax error

New Here ,
Jan 21, 2020 Jan 21, 2020

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;

 

TOPICS
PDF forms
198
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 Expert ,
Jan 21, 2020 Jan 21, 2020
LATEST

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;

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