Acrobat dropdown form to show hide layers with Javascript

Good morning!

Show hide layers from a dropdown in Adobe Acrobat!

I have implemented the script below that may have some errors but I have limited knowledge of JavaScript. I have adapted this script and seems to work locally however when I send it to the client it fails! is there any obvious errors in the following!

Any help much appreciated!!!


var layers = this.getOCGs();
var v = event.value; 
for (var i = 0; i < this.layers.length; i++) {
    if (layers[i].name == "Blank" && v == "BlankOption") {
        layers[i].state = true;
    }
    else if (layers[i].name == "Form1" && v == "Option1") {
        layers[i].state = true;
    }
    else if (layers[i].name == "Form2" && v == "Option2") {
        layers[i].state = true;
    }
        else if (layers[i].name == "Form3" && v == "Option3") {
        layers[i].state = true;
    }
        else if (layers[i].name == "Form4" && v == "Option4") {
        layers[i].state = true;
    }
        else if (layers[i].name == "Form5" && v == "Option5") {
        layers[i].state = true;
    }
        else if (layers[i].name == "Form6" && v == "Option6") {
        layers[i].state = true;
    }
        else if (layers[i].name == "Form7" && v == "Option7") {
        layers[i].state = true;
    }
        else if (layers[i].name == "Form8" && v == "Option8") {
        layers[i].state = true;
    }
        else if (layers[i].name == "Form9" && v == "Option9") {
        layers[i].state = true;
    }
    else if (layers[i].name != "BG-IMAGE"){
        layers[i].state = false;
    }
}