Javascript to turn off ocg / layers beginning with a text string
Hi, I'm trying to turn off all layers that begin with a text string.
So far I have:
var l = this.getField("SELECT.Language").valueAsString;
var n = this.getField("SELECT.Number").valueAsString;
for (var x=0; x < ResetOCGs.length; x++)
{ ResetOCGs[x].state = false; }
for (var x=0; x < docOCGs.length; x++)
{
if(docOCGs[x].name == "Logo" ) { docOCGs[x].state = true; }
if(docOCGs[x].name == l ) { docOCGs[x].state = true; }
if(docOCGs[x].name == l + ".1" ) { docOCGs[x].state = true; }
if(docOCGs[x].name == l + ".2" ) { docOCGs[x].state = false; }
if(docOCGs[x].name == l + ".3" ) { docOCGs[x].state = false; }
if(docOCGs[x].name == l + ".4" ) { docOCGs[x].state = false; }
}
I'd ideally like to get rid of Reset OCGs a turn off layers that begin with l + ".3".
I was thinking something like l + ".3*", with the asterisk acting as a wildcard but it doesn't seem to work.
Can anyone help please?
This is a form created in Acrobat, with all fields created in Acrobat.
