Skip to main content
Participant
October 11, 2018
Question

Execute Javascript action to show/hide all objects and shapes matching criteria

  • October 11, 2018
  • 2 replies
  • 1010 views

I'm currently trying to build a button that will toggle hints (in the form of SmartShapes) and highlights that match a certain criteria from hidden to shown. Because the file is so big (over 600 slides), my current (attempted) approach has two parts.

First part is an Action on Enter for the first slide to Execute Javascript and find every item (highlights and smartshapes with text) that has "Anton_Resources_" in its name and creates a string with the names.

My second step was to create a button that I could drop on each page of the click through to toggle the hints on if needed. I hoped to do this by having a button that executes a javascript to loop through the string and show the objects in the list. (And then another script on exit of page to hide these objects again if the user still has more hints to use before going to "Beginner version" with all the hints and highlights shown for the rest of the simulation.)

These objects and shapes are scattered throughout the project on different pages. They are all named with the same naming convention (Hints are Hint_Anton_Resources_#### and Highlights are Highlight_Anton_Resources_####) so the only thing that changes is the number at the end (though they're not always consistent numbers due to copy and paste or edits along the way).

Ideally this code would work when published to my computer (to be able to confirm it works before sending to LMS). I am using Captivate 2017.

I've tried to find information on how to use cp.D or cp.model.data or even e.Data.si to put something together, but have had no luck and found no comprehensive source of information about how to use these. That said, at this point I just need to get a code that works!

This topic has been closed for replies.

2 replies

Inspiring
October 14, 2018

I would use the CpExtra HTML5 widget from Tristan Ward in this case. Buy CpExtra | Infosemantics Pty Ltd

Lilybiri
Legend
October 14, 2018

Indeed, Vico, that is what I answered by phone, but my answer never made it. Most users now think that they have to use JS where much easier solutions are available.

Inspiring
October 11, 2018
Dwatts7Author
Participant
October 12, 2018

I have but it did not work when I published it. I may have missed something from the larger thread, but putting the “correct“ code into the Execute JavaScript action for my button did not work.

TLCMediaDesign
Inspiring
October 12, 2018

Generally executing loops in the Execute JavaScript function will not work, it needs to be executed in an external JS file, which has a million other advantages.