Skip to main content
Known Participant
February 14, 2020
Question

< smybol not is replaced with < in Execute Javascript window, a bug!!

  • February 14, 2020
  • 1 reply
  • 1064 views

Captivate has lots of bug apparently. I am trying to change the object state with Javascript.

 

my code is like this:

if(var_Progress_Percent>0 && var_Progress_Percent <21) {
    cp.changeState("progress_image_745","p5"); 
  
} else if(var_Progress_Percent>21 && var_Progress_Percent <41) {
    cp.changeState("progress_image_745","p10"); 
    
} 

but when I paste this to captivate Javascript Panel, it displayed like this:

 

if(var_Progress_Percent>0 && var_Progress_Percent &lt;21) {
    cp.changeState("progress_image_745","p5"); 
  
} else if(var_Progress_Percent>21 && var_Progress_Percent &lt;41) {
    cp.changeState("progress_image_745","p10"); 
    
} 

 

 

So nothing works. What is the workaround for this issue?

 

 

This topic has been closed for replies.

1 reply

Stagprime2687219
Legend
February 14, 2020

Perhaps we need to nest that a bit further.

Notice the extra parentheses

 

if ((var_Progress_Percent>0) && (var_Progress_Percent<21)) {
    cp.changeState("progress_image_745","p5"); 
} 
else if ((var_Progress_Percent>21) && (var_Progress_Percent<41)) {
    cp.changeState("progress_image_745","p10"); 
}

 

 

Be careful with copy and paste - that can sometimes be the very reason things break. 

Known Participant
February 14, 2020

Thanks for your suggestion but didn't work.  

RodWard
Community Expert
Community Expert
February 15, 2020

The Captivate JavaScript window is not the greatest editing environment for coding.  As you have discovered, certain characters (e.g. the > and < characters) get changed or misinterpreted.  The better way to handle more complex JS code is to put it in an external file and reference that file in the head of the index.html file.  If you search this forum, you should find several threads about how to set up the template file that Captivate uses to generate the published index.html and where you can put your custom code.