Welcome Dialog

Welcome to the Community!

We have a brand new look! Take a tour with us and explore the latest updates on Adobe Support Community.


Need Help Identifying Cause of Error Message

Explorer ,
May 19, 2021 May 19, 2021

Copy link to clipboard

Copied

Ihave the following script I an placing in the custom calculation for text field "TrailerBodyTypeHideShow". My goal is to allow the user to make selections in previous radio buttons, but keep the two fields ( "TrailerBodyTypeTT" and "TrailerBodyTypeVT" hidden until either the user selected: whether or not the trailer will be fixed to the ground; and, whether the trailer is new or used; and, whether it has a FL title or OOS title.  I keep getting an error message 'Syntax Error 10 at line 10'. Despite many attempted variations I continue to get this message. Here's the latest calc script used and I'm attaching the file also. I've been using Thom Parker's article "Hiding/Showing Fields" as a guide but I must be doing something wrong. Guidance is greatly appreciated- thanks in advance- kemper 

 

var TTB = this.getField("TrailerTypeButtons").value;
var TLFXD = this.getField("TrailerFixedPermenantButtons").value;
var TLNUH = this.getField("TrailerNewUsedButtons").value;
var TLTIT = this.getField("TrailerTitleButtons").value;

if ((TTB != "VT") && (TLFXD != "") && (TLNUH == "New") || (TLTIT != ""))
this.getField("TrailerBodyTypeTT").display = display.visible;
this.getField("TrailerBodyTypeVT").display = display.hidden;

else if ((TTB == "VT") && (TLFXD == "") && (TLNUH == "New") || (TLTIT != ""))
this.getField("TrailerBodyTypeTT").display = display.hidden;
this.getField("TrailerBodyTypeVT").display = display.visible;

TOPICS
JavaScript

Views

479

Likes

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
Adobe Community Professional ,
May 19, 2021 May 19, 2021

Copy link to clipboard

Copied

You are missing curly brackets {} after your both conditions.

Likes

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
Adobe Community Professional ,
May 19, 2021 May 19, 2021

Copy link to clipboard

Copied

It's because you're not using curly braces with the if statements. It should be:

 

 

var TTB = this.getField("TrailerTypeButtons").value;
var TLFXD = this.getField("TrailerFixedPermenantButtons").value;
var TLNUH = this.getField("TrailerNewUsedButtons").value;
var TLTIT = this.getField("TrailerTitleButtons").value;

if ((TTB != "VT") && (TLFXD != "") && (TLNUH == "New") || (TLTIT != "")) {
    this.getField("TrailerBodyTypeTT").display = display.visible;
    this.getField("TrailerBodyTypeVT").display = display.hidden;
} else if ((TTB == "VT") && (TLFXD == "") && (TLNUH == "New") || (TLTIT != "")) {
    this.getField("TrailerBodyTypeTT").display = display.hidden;
    this.getField("TrailerBodyTypeVT").display = display.visible;
}

 

Likes

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
Adobe Community Professional ,
May 19, 2021 May 19, 2021

Copy link to clipboard

Copied

Note that I did not analyse the code for correct logic, rather syntax only.

Likes

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
Explorer ,
May 20, 2021 May 20, 2021

Copy link to clipboard

Copied

Thank you George and Nesa for your responses and guidance! Under what circumstances are the curly brackets required and why? 

Likes

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
LEGEND ,
May 20, 2021 May 20, 2021

Copy link to clipboard

Copied

The "if" has no way to know that you want it to apply to two lines. Only you know that! So you put the brackets to tell it that this is the thing you want to apply to { thing ... thing ... thing } is just one thing because of the brackets.

Likes

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
Adobe Community Professional ,
May 20, 2021 May 20, 2021

Copy link to clipboard

Copied

LATEST

If you always include the brackets, you don't have to worry about when they need to be used.

Likes

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