Hi,
I'd like to use above script to show and hide few selections of DIVS on click on links.
I have 6 links and I'd like to those links show defined selections of DIVs and hide any other:
link1 - div1, div2, div10, div11
link2 - div1, div6, div9
link3 - div1,div4,div5
link4 - div1,div5,div14
link5 - div1,div7,div8,
link6 - div1,div4,div5,div10,div11,div12,div13
My code in <HEAD> is like below:
Code:
<script type="text/javascript">
// <![CDATA[
var divs = ["div1", "div2", "div3", "div4", "div5", "div6", "div7", "div8", "div9", "10", "11", "12", "13", "14"];
var divs121011 = ["div1", "div2", "div10", "div11"]; /*autor*/
var divs169 = ["div1", "div6", "div9"]; /*praca*/
var divs145 = ["div1", "div4", "div5"]; /*wyszukiwarka*/
var divs1514 = ["div1", "div5", "div14"]; /*miniblog*/
var divs178 = ["div1", "div7", "div8"]; /*projkty*/
var div14510111213 = ["div1", "div4", "div5", "div7", "div8"]; /*wiecej*/
function visiblox(arrDiv, hs) {
var disp = (hs) ? "none" : "inline";
for(var x = 0; x < arrDiv.length; x++) {
document.getElementById(arrDiv[x]).style.display = disp;
}
}
function chk(what, item) {
if(item) {
visiblox(what, false);
} else {
visiblox(what, true);
}
}
// ]]>
</script>
<style type="text/css">
<!--
.show { display: inline; }
.hide { display: none; }
-->
</style>
In <BODY> like below:
Code:
<div id="menu">
<ul>
<li><a href="#div1" class="autor-link" onClick="javascript:chk(divs121011, this.checked);">meet <b>author</b></a></li>
<li><a href="#div6" onclick="javascript:chk(divs169, this.checked);">Status</a></li>
<li><a href="#div4" onclick="javascript:chk(divs145, this.checked);">Search</a></li>
<li><a href="#div14" onclick="javascript:chk(divs1514, this.checked);">Miniblog</a></li>
<li><a href="#div7" onclick="javascript:chk(divs178, this.checked);">Projects</a></li>
<li><a href="#div1" onclick="javascript:chk(divs14510111213, this.checked);">More</a></li>
</ul>
</div>
<div id="div1" class="hide">Some text and graphics.
<div id="div2" class="hide">Some text and graphics.</div>
<div id="div3" class="hide">Some text and graphics.</div>
</div>
<div id="div4" class="hide">Some text and graphics.</div>
<div id="div5" class="hide">Some text and graphics.</div>
<div id="div6" class="hide">Some text and graphics.</div>
<div id="div7" class="hide">Some text and graphics.</div>
<div id="div8" class="hide">Some text and graphics.</div>
<div id="div9" class="hide">Some text and graphics.</div>
<div id="div9" class="hide">Some text and graphics.</div>
</div>
<div id="div10" class="hide">Some text and graphics.
<div id="div11" class="hide">Some text and graphics.</div>
</div>
<div id="div12" class="hide">Some text and graphics.
<div id="div13" class="hide">Some text and graphics.</div>
</div>
<div id="div14" class="hide">Some text and graphics.</div>
What I like to do is to have all DIVs hidden until user click on link, then display set of DIVs and when user click on other link to hide other and show DIVs only from selected set.
Can anyone help me with this?
Bookmarks