CP9 - Hide a Group using JavaScript - Is there a better solution?
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.
