function setTaps(tap) { let drop = this.getField("NumberOfTaps"+tap).value; let childMask = new RegExp("^" + tap + "-[\\d]{1,2}$"); //Creates an array of all layer names let layerList = this.getOCGs(); //this loop will cycle through each layer name and perform the following for each for (let i = 0; i < layerList.length; i++) { //creates a variable to hold the current layer name for testing var fname = layerList[i].name; //checks to see if this is a child of group 10 if (childMask.test(fname)) { if (fname.substring(fname.indexOf("-") + 1) > drop) { //if substring after the dash is greater than the drop value layerList[i].state = false; layerList[i].initstate = false; } else { layerList[i].state = true; layerList[i].initstate = true; } } } }