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

CP9 - Hide a Group using JavaScript - Is there a better solution?

Engaged ,
Mar 09, 2018 Mar 09, 2018

Copy link to clipboard

Copied

CP9 - HTML5 only

Hello,

I need to hide Groups using Javascript stored in an external library.

It appears that Javascript cannot hide a Group using the Group name.

The only way to do it is to hide each individual item in the group.

Although this is tedious and requires the names of the items in the Group to be numbered, it is the only way I know of doing this.

If anyone can suggest a better way I would really appreciate it, as I have about 100 groups that I need to do this with.

Thank you

Peter

This is my code:

function myHideGroup(GroupName){

// Hide all items in a Group.

// Items in the Group must be named with the Group name followed by a number.

// Example item names, 'doctor01' 'doctor02' etc.

// Name of the group to be hidden.

   var tmpGroupName = GroupName;

// Define vars to use.

   var tmpItemName  = "";

   var tmpItemNumber = "";

// Loop through all the items in the group.

   var myLoop;

   for (myLoop = 1; myLoop <= 50; myLoop++) {

     //Convert item number to a string so it can be used in the item name.

       var tmpItemNumber = myLoop.toString();

     //Pad the item number with zeros to match my names in captivate.

       while (tmpItemNumber.length < 2) {tmpItemNumber = '0' + tmpItemNumber;}

     //Concat the GroupName and ItemNumber to create the name of item to be hidden, such as 'doctor01'.

       var tmpItemName = tmpGroupName.concat(tmpItemNumber);

     //Hide the item

       cp.hide(tmpItemName);

       }

End of message.

Views

2.8K

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

correct answers 1 Correct answer

People's Champ , Mar 12, 2018 Mar 12, 2018

You are correct that there are no groups when the file is published. Captivate just executes script to hide all of the individual objects the same as what your script is doing.

I use a script that resets the slide to all objects original visibility state and then shows the objects with the specific naming convention.

Your script could be modified slightly to get all of the items on a slide and check if the GroupName is in the name of the element.

Since jQuery is available you can just do this:

hideG

...

Votes

Translate

Translate
Contributor ,
Apr 27, 2021 Apr 27, 2021

Copy link to clipboard

Copied

LATEST

Hi, 

It works like a charm!!

I really hit a dead end with my fumbling around. II never thought about using chartAt and i++.

🙂

Thank you both to G and TLC 🙂

 

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