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.
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
...Copy link to clipboard
Copied
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 🙂