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

Need Help Identifying Cause of Error Message

Contributor ,
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

750

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

Copy link to clipboard

Copied

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

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
LEGEND ,
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;
}

 

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
LEGEND ,
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.

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
Contributor ,
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? 

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
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.

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
LEGEND ,
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.

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