If the name of my layer in openlayers is "olayer". And if i want to set its visibility to true. Then the simple code is
But if i want to set the visibility by storing the layer's name in a different variable like this:
var vari="olayer"; vari.setVisibility(true);
This won't work because its taking "vari" as the name of the layer instead of the string stored in variable "vari".