Skip to main content
Known Participant
August 5, 2019
Question

Can someone help me with creating a javascript please?

  • August 5, 2019
  • 2 replies
  • 1221 views

i Have a javascript that can turn the layers i want on. but what i would love to include is script that will turn some other layers off once the layer is toggled on. Here is what i have so far.

var docOCGs = this.getOCGs();

for (var x=0; x < docOCGs.length; x++)

{

          if(docOCGs.name == "Cadent Trace" ||

     docOCGs.name == "Cadent Trace")

          {

                    docOCGs.state = !docOCGs.state;

          }

}

I am very new to java and am learning the basics at the moment so any help will be much appreciated!

thanks, Max

This topic has been closed for replies.

2 replies

try67
Community Expert
Community Expert
August 5, 2019

Do you want to hide all other layers, or just some?

Known Participant
August 5, 2019

Just some layers not all.

try67
Community Expert
Community Expert
August 5, 2019

OK, but your code doesn't just set some layers as visible. It changes their state from visible to hidden, or the other way around.

So should these other layers also be changed to the opposite state from their current one?

Karl Heinz  Kremer
Community Expert
Community Expert
August 5, 2019

Try to describe in words exactly what your script is supposed to do - e.g. something like "I have three layers 'layerA', 'layerB' and 'layerC', and when XYZ happens, then layer A and layerB should be shown, layerC should be hidden. When ABC happens, then layerA should be hidden and layerB and layerC should be visible.

Based on your question it's not clear what you want the script to do.

Known Participant
August 5, 2019

Sorry ill try to explain better. If 'Layer 1' is on then 'Layer 2', 'Layer 3' & 'Layer 4' should be off. I want to be able to switch between these for example if 'layer 2' is visible then 'layer 1', 'layer 3' & ' layer 4' should not be visible and so on. I hope this explains it a bit better.