Submit Your Article 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 May 19th, 2008, 10:28 AM   #1
New Member
 

Join Date: Apr 2008
Location: UK
Age: 37
Posts: 7
Thanks: 1
Thanked 0 Times in 0 Posts
Rep Altering Power: 0 thintin is on a distinguished road
Question lil bit of help needed

Hi.

I'm trying to use some code to hide/unhide divs that occupy the same space on the screen so that the content is selected by clicking a relevant link in another div.

it's working, sort of, but I need to add some script to close the last unhidden div when another link is clicked.

currently the new unhidden divs appear below the previous ones unless they are re-clicked to close em :-S

the page in question is here: http://www.philtinsley.com/about.html
(i've just sent the updated pages to the server but if you get 'under construction' writen in the middle of the page, you're seeing the old one)

any help very much appreciated :-)
thintin 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
Old May 19th, 2008, 06:12 PM   #2
Most Reputable Member
 

Join Date: Feb 2008
Location: In My Own Little World
Age: 16
Posts: 1,345
Blog Entries: 9
Thanks: 2
Thanked 45 Times in 45 Posts
Rep Altering Power: 0 CloudedVision is on a distinguished road
Re: lil bit of help needed

How you would do that would to first cycle through all the other divs and hide those before showing the correct one. If I'm right in assuming that you have very basic javscript skills, I'll run you through this step by step.

First, lets make the function

Code:
function show(div_id) {
it looks like the div "blank_space" is the parent of all those other divs, so we'll get that.

Code:
parent = document.getElementById("blank_space");
Next, we need to cycle though all the child divs of that object and hide that

Code:
i = 0;
while(cur_item = parent.childNodes[i]) {
  cur_item.style.display = 'none';
  i++;
}
Then lets unhide the div that you want to show.

Code:
document.getElementById(div_id).style.display = '';
Done! Let's put it all together

Code:
function show(div_id) {
parent = document.getElementById("blank_space");
i = 0;
while(cur_item = parent.childNodes[i]) {
  cur_item.style.display = 'none';
  i++;
}
document.getElementById(div_id).style.display = '';
}
Edit: I haven't tested this. Any errors just hit the "Post Reply" button.
__________________
Theron Luhn

Last edited by CloudedVision; May 19th, 2008 at 06:16 PM..
CloudedVision 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
Old May 20th, 2008, 04:15 AM   #3
New Member
 

Join Date: Apr 2008
Location: UK
Age: 37
Posts: 7
Thanks: 1
Thanked 0 Times in 0 Posts
Rep Altering Power: 0 thintin is on a distinguished road
Re: lil bit of help needed

"If I'm right in assuming that you have very basic javscript skills" on the head! (didn't think it would be that obvious :-)

Sounds good and thanks for your time and effort.

Do I add that script onto the script I already have? and if so, does it matter where I add it?

~thanks, Phil.
thintin 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
Old May 20th, 2008, 08:37 AM   #4
Most Reputable Member
 

Join Date: Feb 2008
Location: In My Own Little World
Age: 16
Posts: 1,345
Blog Entries: 9
Thanks: 2
Thanked 45 Times in 45 Posts
Rep Altering Power: 0 CloudedVision is on a distinguished road
Re: lil bit of help needed

Just replace the unhide() function with the show() function that I gave you
__________________
Theron Luhn
CloudedVision 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
Old May 20th, 2008, 10:14 AM   #5
New Member
 

Join Date: Apr 2008
Location: UK
Age: 37
Posts: 7
Thanks: 1
Thanked 0 Times in 0 Posts
Rep Altering Power: 0 thintin is on a distinguished road
Re: lil bit of help needed

Thanks. I've replaced my 'unhide' code with your 'show' one. But now no divs appear... do I have to change anything in the <body> code?
thintin 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
Old May 20th, 2008, 10:19 AM   #6
New Member
 

Join Date: Apr 2008
Location: UK
Age: 37
Posts: 7
Thanks: 1
Thanked 0 Times in 0 Posts
Rep Altering Power: 0 thintin is on a distinguished road
Re: lil bit of help needed

tried changing the references in the <body> from 'unhide' to 'show' but it hasn't changed anything?
thintin 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
Old May 20th, 2008, 04:28 PM   #7
Most Reputable Member
 

Join Date: Feb 2008
Location: In My Own Little World
Age: 16
Posts: 1,345
Blog Entries: 9
Thanks: 2
Thanked 45 Times in 45 Posts
Rep Altering Power: 0 CloudedVision is on a distinguished road
Re: lil bit of help needed

I went to the page, but don't see the show() function anywhere.
__________________
Theron Luhn
CloudedVision 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


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
SEO Help Needed Merlin Search Engine Optimization (SEO) 20 September 3rd, 2007 03:26 AM
help with nav bar needed please help bruno89 HTML, XHTML and CSS 1 February 23rd, 2006 04:08 PM
help needed stargazer Web Hosting and Domains 1 September 11th, 2005 12:10 PM


Search Engine Optimization by vBSEO 3.2.0 RC8