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

Adobe Javascript If/Else Statements with empty cells

New Here ,
Oct 15, 2020 Oct 15, 2020

Copy link to clipboard

Copied

I am trying to create a calculation sheet that only shows the result of the calculation if there is a number put in the cells above it. The values in the cells can vary from a negative numbers to positive including zero. I am trying to use this expression but it keeps throwing "SyntaxError: syntax error 26: at line 27"

____________________________________________________

var B8 = this.getField("B8").value;
var B9 = this.getField("B9").value;
var C5 = this.getField("C5").value;
var C6 = this.getField("C6").value;
var C7 = this.getField("C7").value;
var C8 = this.getField("C8").value;

var GOAL = C7+(B9-(C8-B8))+C5-C6+25;


if( C5 != "" ) {
event.value = GOAL;
}
or ( C6 != "" )
{
event.value = GOAL;
}
or ( C7 != "" )
{
event.value = GOAL;
}
or ( C8 != "" )
{
event.value = GOAL;
}
else {
event.value = " ";
}

TOPICS
Acrobat SDK and JavaScript

Views

442

Translate

Translate

Report

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 2 Correct answers

Community Expert , Oct 15, 2020 Oct 15, 2020

Replace the "or" with "else if".

Votes

Translate

Translate
Community Expert , Oct 31, 2020 Oct 31, 2020

The basic Boolean logical operator for "Or"  is " || ". And also, when you are using a comparison operator with a logical statement to determine a difference in values (or  between variables)  you should employ "!==" ( not equal value or not equal type with the double equal comparison operator).

 

Last, in your last line,  you're declaring the null statement for the event value with " " (a spcae in between the quotes); the quotes should be together "". Otherwise, you're declaring a statement bas

...

Votes

Translate

Translate
Community Expert ,
Oct 15, 2020 Oct 15, 2020

Copy link to clipboard

Copied

Replace the "or" with "else if".

Votes

Translate

Translate

Report

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 ,
Oct 31, 2020 Oct 31, 2020

Copy link to clipboard

Copied

LATEST

The basic Boolean logical operator for "Or"  is " || ". And also, when you are using a comparison operator with a logical statement to determine a difference in values (or  between variables)  you should employ "!==" ( not equal value or not equal type with the double equal comparison operator).

 

Last, in your last line,  you're declaring the null statement for the event value with " " (a spcae in between the quotes); the quotes should be together "". Otherwise, you're declaring a statement based on a value that corresponds to a single space character string inside of the quotes.

 

Is there a specific reason why yo needed to declare the event value like this?

 

I would deploy your script like this:

 

var B8 = this.getField("B8").value;
var B9 = this.getField("B9").value;
var C5 = this.getField("C5").value;
var C6 = this.getField("C6").value;
var C7 = this.getField("C7").value;
var C8 = this.getField("C8").value;

var GOAL = C7+(B9-(C8-B8))+C5-C6+25;

event.value = "";

if ( ( C5 !== "" ) || ( C6 !== "" ) || ( C7 !== "" ) || ( C8 !== "" ) ) {event.value = GOAL;}

 

 

 

 

Votes

Translate

Translate

Report

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