This is a discussion on "hidng divs with javascript" within the JavaScript Forum section. This forum, and the thread "hidng divs with javascript are both part of the Program Your Website category.
|
|
|
|
|
![]() |
||
hidng divs with javascript
|
||
| Notices |
![]() |
|
|
LinkBack | Thread Tools |
|
|||
|
hidng divs with javascript
Hi Im trying to hide div classes with the following method:
Thanks in advance. Eon201 ;D |
|
|
|
|||
|
Re: hidng divs with javascript
This code is highly misleading. Your functions say, "setVisibility(class, visibility)", but really it's operating on IDs: "document.getElementById".
Change all your <div> classes to IDs, and it should work. This will mean a lot more function calls, however. Alternatively, keep the classes and write something like:
|
|
|||
|
Re: hidng divs with javascript
Thanks mike. I have now changed the classes to id's and it has done the trick, although I do have to call each seperatly. Long winded code but it does the job well!
Thanks for the help. Eon201 |
|
||||
|
Re: hidng divs with javascript
you can check out these links to see some examples:
http://www.plus2net.com/javascript_t...hide-layer.php http://www.geocities.com/technofundo.../showhide.html http://www.adesdesign.net/php/tutori...hide_div.html# http://www.dyn-web.com/dhtml/show-hide/
__________________
WelshStew Lead Administrator tierney rides tboard - uk site | xtreme wales - extreme clothing If you think I've helped, click the "Thanks" webforumz - facebook | LinkedIn
Last Blog Entry: Web Standards Curriculum Launched (Jul 8th, 2008)
|
|
||||
|
Re: hidng divs with javascript
If you are using just one class per div you could use something like
onclick="setVisibility(new Array('a'), 'inline'); setVisibility(new Array('b','c','d','e','f','etc'), 'none');" This should knock it back to two function calls per click, the code is a doing a bit more work than before but because the divs are held in reference from the outset, cycling through a few arrays is not a big overhead and it decreases the amount of code which is cleaner and faster to load. Hope that helps,
Last Blog Entry: The wannabe juggler's quest (Oct 27th, 2007)
|
|
|||
|
Re: [SOLVED] hidng divs with javascript
Thanks guys.
As helpfull as ever! Eon201 |
|
|||
|
Re: [SOLVED] hidng divs with javascript
So. that part is sorted. Brilliant advice as always.
Here comes the bit that is v confusing for me. So the code currently looks like so.
The page has to refresh. This again works. The only problem is if you are displaying the 'b' divs and the page refreshes it shows divs 'a' by default. Is there anyway to lose the meta refresh and have a javascript one that refreshes every 30 secs but will keep displaying the selected divs?? I hope this isnt confusing - if it is please say so! Thanks in advance Eon201. |
![]() |
| Thread Tools | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| [SOLVED] Im getting a gap between 2 divs :-( | danny322 | Web Page Design | 1 | Jan 9th, 2008 08:46 |
| Having two divs which do not affect each other? | LGS | Web Page Design | 11 | Oct 28th, 2007 23:41 |
| Divs in a row | hessodreamy | Web Page Design | 5 | Feb 17th, 2006 18:40 |
| Divs in a row | hessodreamy | Web Page Design | 1 | Nov 15th, 2005 15:58 |