Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

JavaScript Forum


You are currently viewing our JavaScript Forum as a guest. Please register to participate.
Login



Reply
Help! Multi Show&Hide + Cookies
Old 03-01-2009, 05:33 PM Help! Multi Show&Hide + Cookies
Junior Talker

Posts: 1
Trades: 0
Hello, Everyone. This is my first time here at the forums. I'm in need of help finding or finishing this script I've already have.

Need
Cookies added on this script posted below to allow their browser to remember last divs was selected when they come back or refresh.

Could Use
Any other type of script that uses same funtions of the one below with cookies if can't be wrote in same way or added on.

What Script does
It's a multi show and hide which hides all div's at start until user clicks on a link to show multi divs selected inside link coding. Once a div is clicked it hides all other divs which isn't coding inside the link selected.

Script
HTML Code:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
    <meta http-equiv="Content-type" content="text/html; charset=UTF-8" />
    <title></title>
    <meta http-equiv="Content-Language" content="en-us" />
    <meta name="author" content="" />

<script type="text/javascript">

function show(obj){

oDiv=document.getElementsByTagName("DIV")

for(var i=0;i<oDiv.length;i++){
if(oDiv[i].className=="hidden_element"){
oDiv[i].style.visibility="hidden"
}
}

for(var j=0;j<arguments.length;j++){
document.getElementById(arguments[j]).style.visibility="visible";
}

}

</script>

<script type="text/javascript">
function hideDivs(){
var arr = document.getElementsByTagName('div')
for(var i=0; i<arr.length;i++){
arr[i].style.display = (arr[i].style.display == 'block')? 'none':'block';
}
}
</script>

</head>

<body>

Showing : 
<br>
<br>
<a href="#" onclick="show('div1','sdiv1')">div 01</a><br>
<a href="#" onclick="show('div2','sdiv2')">div 02</a><br>
<a href="#" onclick="show('div3','sdiv3')">div 03</a><br>


<div class="hidden_element" id="sdiv1" style="position: absolute; top: 8px; left: 70px; visibility:hidden; ">
Div 01
</div>
<div class="hidden_element" id="sdiv2" style="position: absolute; top: 8px; left: 70px; visibility:hidden; ">
Div 02
</div>
<div class="hidden_element" id="sdiv3" style="position: absolute; top: 8px; left: 70px; visibility:hidden; ">
Div 03
</div>

<div class="hidden_element" id="div1" style="position: absolute; top: 8px; left: 150px; visibility:hidden; ">
This is random content of Div 01
</div>

<div class="hidden_element" id="div2" style="position: absolute; top: 8px; left: 150px; visibility:hidden; ">
This is random content of Div 02
</div>

<div class="hidden_element" id="div3" style="position: absolute; top: 8px; left: 150px; visibility:hidden; ">
This is random content of Div 03
</div>

</body>
</html>
unknownsoul is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Reply     « Reply to Help! Multi Show&Hide + Cookies
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.29905 seconds with 12 queries