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

JavaScript Arithmetic Operators Syntax

New Here ,
Aug 19, 2016 Aug 19, 2016

Copy link to clipboard

Copied

I am using Captivate 9 and executing a JavaScript from within an advanced action.

What is the correct syntax for comparing two variables in a conditional statement?

e.g To check equality I have successfully used the syntax..... if(x == y){

                                                                                                   var z = 1;

                                                                                                }

however when I try to check for the arithmetic operator ...."is less than", Captivate 9 will not allow me to  "update" the script....

e.g.           I tried.....      if(x < y){

                                        var z = y;

                                     }

I know that an advanced action script does not offer a "<" arithmetic operator Does that mean that  javascript that is executed within an advanced action, also will not allow the "is less than" arithmetic operation??

Thank you for your assistance.

Views

408

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
People's Champ ,
Aug 19, 2016 Aug 19, 2016

Copy link to clipboard

Copied

You can use less than in an advanced action.

Certain characters can't be used in the JavaScript window. your best bet is to put the script in the html head or an external js file.

X < Y is the same thing as Y > X though if it will allow you to use the greater than symbol.

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
New Here ,
Aug 19, 2016 Aug 19, 2016

Copy link to clipboard

Copied

Thank you.

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 ,
Aug 20, 2016 Aug 20, 2016

Copy link to clipboard

Copied

You do underestimate advanced/shared actions. Most logical parameters are available.

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
New Here ,
Sep 24, 2019 Sep 24, 2019

Copy link to clipboard

Copied

Thanks for confirming what I realized, after chasing my tail for an hour, must be yet another Captivate bug. The inability to recognize the < symbol is just another example of why Captivate is an inferior product.

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
Engaged ,
Sep 24, 2019 Sep 24, 2019

Copy link to clipboard

Copied

LATEST

Some work around: write out the code in an external editor first, then replace < by &lt (HTML Number for '<') or &#60 (HTML Name for '<') before copying code to the Script Window in an Advanced Action. On saving the Script Window, those strings will be properly escaped and converted to the '<' character. Note that you'll have to cover all '<' character occurrences in the code at once in every copy and past action. You can't just edit/add one of several occurrences that way, so it's probably good advise to always copy the entire code to a blank Script Window in one shot. You can also type the HTML Number/Name strings directly into the Script Window, but again you'd have to make sure to enter all occurrences in one shot. See https://forums.adobe.com/message/10709838

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
Resources
Help resources