Behavior Question

F

Fred M

Is there a way to make the visibility of a layer dependent on whether an
Option Button is checked or not?
 
M

Murray

You mean when you click on the button the layer appears/disappears? Sure -
that would be the Change Property behavior.
 
F

Fred M

Yes, that's what I'd like to do but it looks like I can only change the
property to visible or hidden which means it works with the first click but
then stays visible or hidden for any subsequent clicks. I don't see an
option to "toggle" the visibility property.
 
M

Murray

There is not such an option. If you want to toggle the visibility, it's
quite possible, but you'd have to create the custom javascript yourself, or
find a 3rd part script that will do that.
 
F

Fred M

Thanks Murray, that's what I needed to know.

Murray said:
There is not such an option. If you want to toggle the visibility, it's
quite possible, but you'd have to create the custom javascript yourself, or
find a 3rd part script that will do that.
 
M

Murray

Thanks. Custom js would be the way to go - you can apply it with an onClick
applied to the button....

Put this in the head of the page (shameless cribbed from a Dreamweaver
page) -
<script language="JavaScript">
<!--
var clicks=true;
function toggle(layer){
MM_showHideLayers(layer,'',cli­cks?'hide':'show'); clicks=!clicks;


}

function MM_findObj(n, d) { //v4.01
var p,i,x; if(!d) d=document;
if((p=n.indexOf("?"))>0&&parent.frames.length) {
d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++)
x=d.forms[n];
for(i=0;!x&&d.layers&&i<d.layers.length;i++)
x=MM_findObj(n,d.layers.document);
if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_showHideLayers() { //v6.0
var i,p,v,obj,args=MM_showHideLayers.arguments;
for (i=0; i<(args.length-2); i+=3) if ((obj=MM_findObj(args))!=null)
{ v=args[i+2];
if (obj.style) { obj=obj.style;
v=(v=='show')?'visible':(v=='hide')?'hidden':v; }
obj.visibility=v; }
}
//-->
</script>

and in the body, something like this -


<div id="yourlayer" style="position:absolute; left:100px; top:57px;
width:427px; height:46px; z-index:1">
whatever content</div>


<input type="radio" value="V1" checked name="R1"
onclick="toggle('yourlayer')" >
 
R

Ronx

Option buttons are normally used in groups of 2 or more. You can set
one button to hide the layer(s) corresponding to the other button(s)
in the group.
The last layer opened will still remain open, however, unless you add
a button to the group to close all layers.
 
F

Fred M

Thanks, that did it.

Ronx said:
Option buttons are normally used in groups of 2 or more. You can set
one button to hide the layer(s) corresponding to the other button(s)
in the group.
The last layer opened will still remain open, however, unless you add
a button to the group to close all layers.
 
Top