View Full Version : Question about hidden layers
mastahkaz
11-08-2002, 05:11 PM
ok, say i have two hidden layers. And then 1 button that you click that calls the layer to become visible. Now... is there a way to assign that button what layer to call up by selecting a radio button, check box, image, etc.
So por empleo... you click Radio Button 1 (layer 1) and then click the SHOW POP UP button, and layer 1 will be displayed. Or if you clicked Radio Button 2 (layer 2) then clicked the SHOW POP UP button, layer 2 would become visable.
Anyone have an idea?
kdjoergensen
11-08-2002, 05:32 PM
Example:
[code]
<script language="javascript">
<!--
var NS4 = (document.layers) ? 1 : 0;
var IE = (document.all) ? 1 : 0;
var DOM = (document.getElementById) ? 1 : 0;
var hideLayer = (NS4) ? "hide" : "hidden";
var showLayer = (NS4) ? "show" : "visible";
function showIt(form){
layerName = findName(form);
whichOne = getObjRef(layerName);
if (whichOne){
whichOne.visibility = showLayer;
}
}
function hideIt(form){
layerName = findName(form);
whichOne = getObjRef(layerName);
if (whichOne){
whichOne.visibility = hideLayer;
}
}
function findName(form){
var layerName = false;
for (var i=0;i<form.lay.length;i++){
if (form.lay[i].checked){
layerName = form.lay[i].value;
break;
}
}
return layerName;
}
function getObjRef(layerName){
layerObjStyle = (NS4) ? document.layers[layerName] : (DOM) ? document.getElementById(layerName).style : document.all[layerName].style;
return layerObjStyle;
}
//-->
</script>
<form name="myform">
Layer 1: <input type="radio" name="lay" value="item1"><br/>
Layer 2: <input type="radio" name="lay" value="item2"><br/>
<input type="button" value="show layer" onclick="showIt(this.form)">
<input type="button" value="show layer" onclick="hideIt(this.form)">
</form>
<br/>
<br/>
<div id="item1" style="visibility: hidden; position: absolute; top 300px; left 300px;">
Here is one
</div>
<div id="item2" style="visibility: hidden; position: absolute; top 600px; left 600px;">
Here is two
</div>
mastahkaz
11-11-2002, 03:13 AM
nevermind, i figured it out, thanks
vBulletin® v3.6.7, Copyright ©2000-2009, Jelsoft Enterprises Ltd.