iEntry 10th Anniversary Webforumz RegistrationAnnouncements Contact Webforumz StaffContact
Home Resources Blogs Meet the Team Contact Register
 

Go Back   WebForumz.com > The Code > JavaScript

Reply
 
LinkBack Thread Tools
Old April 6th, 2007, 04:18 PM   #1
Most Reputable Member
 

Join Date: May 2006
Location: North West, UK
Age: 23
Posts: 1,170
Thanks: 0
Thanked 0 Times in 0 Posts
Rep Altering Power: 0 pa007 has a spectacular aura about pa007 has a spectacular aura about
Show/Hide JS

Ok, so I've got a piece of javascript that changes the display state of a set of divs from none to block or vice versa. My problem is that if you have one div display: block; and you click on another link the next div just displays below the first one rather than replacing it.

Here's my code:
Code:
var state = 'hidden';

function showhide(layer_ref) {

if (state == 'block') {
state = 'none';
}
else {
state = 'block';
}
if (document.all) { //IS IE 4 or 5 (or 6 beta)
eval( "document.all." + layer_ref + ".style.display = state");
}
if (document.layers) { //IS NETSCAPE 4 or below
document.layers[layer_ref].display = state;
}
if (document.getElementById && !document.all) {
maxwell_smart = document.getElementById(layer_ref);
maxwell_smart.style.display = state;
}
}
So is there any way for the divs to swap on click rather than just to display one under the other? Or when another link is clicked for all of the other divs (not all of the divs on the page though) to revert to display:none; except the one which is being activated?

Thanks,

Pete.
pa007 is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
Reply

Bookmarks

Tags
hide , javascript , show


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools

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 On
Pingbacks are On
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
Show/Hide Div Help Trebz JavaScript 3 April 27th, 2009 10:13 PM
Show/hide/add textfields from dropdownmenu UD2006 JavaScript 0 April 9th, 2008 05:36 AM
CSS Show Hide with JS abis123 JavaScript 4 December 13th, 2007 02:39 AM
[SOLVED] Show&Hide Div Box Maska JavaScript 6 October 1st, 2007 08:04 AM
Show and Hide Text - how do I do that? Love2Java JavaScript 1 March 28th, 2007 09:23 PM


Search Engine Optimization by vBSEO 3.2.0 RC8