Hey Thom,
So I read the article but still a little lost on how to build the code. Sorry, I don't have a strong background in javascripting.
Still looking for a way to reset the layers initial view based on a check boxed in the PDF. >If check box is on when I save > open the file with that layer and check box on.
As Try67 explained in the other thread, there are issues with manipulating Layers in Reader. So, if you can't change the OCG state so that it maintains its value, you save the desired state a different way and restore it on Document Open. One easy way to do this is with "doc.viewState".
So you need hidden text field to save the Layer state, lets call it "LayerState". Then on document close, or anytime you change Layer visibility, call this code:
this.getField("LayerState").value = eval(viewState.toSource()).ocgStates.toSource();
Next, add this code to a Document Script:
viewState = {ocgStates:eval(this.getField("LayerState").value)};
This is not as good as setting the initialState for the layer, but it works for Acrobat/Reader. Probably won't work for any other viewer.