Today's Posts Follow Us On Twitter! TFL Members on Twitter  
Forum search: Advanced Search  
Navigation
Marketplace
  Members Login:
Lost password?
  Forum Statistics:
Forum Members: 24,254
Total Threads: 80,792
Total Posts: 566,471
There are 1483 users currently browsing (tf).
 
  Our Partners:
 
  TalkFreelance     Design and Development     Programming     Javascript :

Bit of help needed!

Thread title: Bit of help needed!
Closed Thread    
    Thread tools Search this thread Display Modes  
02-17-2007, 07:45 PM
#1
t0m is offline t0m
Status: Request a custom title
Join date: Jan 2005
Location: West Sussex, England
Expertise:
Software:
 
Posts: 2,829
iTrader: 21 / 100%
 

t0m is on a distinguished road

  Old  Bit of help needed!

Ok im just trying to show/hide a div - everything on this script is working perfect BUT i want it to be hidden when the page loads...(at the momment it shows by default).

Thanks for the help!

Code:
<html>

<head>
<title>Test!</title>

<script language=javascript type='text/javascript'>
document.onload=hidelayer;

function showdiv() {
if (document.getElementById) { // DOM3 = IE5, NS6
document.getElementById('hideshow').style.visibility = 'visible';
}
else {
if (document.layers) { // Netscape 4
document.hideshow.visibility = 'visible';
}
else { // IE 4
document.all.hideshow.style.visibility = 'visible';
}
}
}
function hidediv() {
if (document.getElementById) { // DOM3 = IE5, NS6
document.getElementById('hideshow').style.visibility = 'hidden';
}
else {
if (document.layers) { // Netscape 4
document.hideshow.visibility = 'hidden';
}
else { // IE 4
document.all.hideshow.style.visibility = 'hidden';
}
}
}


</script> 

</head>

<body>

<a href="javascript:hidediv()">hide div</a>
<a href="javascript:showdiv()">show div</a>

<div id="hideshow">
My content test, please hide show!
</div>
</body>

</html>

02-17-2007, 07:49 PM
#2
theolatic is offline theolatic
Status: Member
Join date: Dec 2005
Location: Staffordshire, UK
Expertise:
Software:
 
Posts: 375
iTrader: 1 / 100%
 

theolatic is on a distinguished road

Send a message via MSN to theolatic

  Old

try setting the div to hide in the style sheet.

visibility:hidden;

02-17-2007, 07:50 PM
#3
localhost is offline localhost
localhost's Avatar
Status: Dediport Hosting
Join date: Jul 2006
Location: Berkshire
Expertise: programming, business
Software: Dreamweaver
 
Posts: 1,316
iTrader: 17 / 100%
 

localhost is on a distinguished road

  Old

change <body>
to
<body onload="hidediv()">

Tell me if this works..

02-17-2007, 07:54 PM
#4
t0m is offline t0m
Status: Request a custom title
Join date: Jan 2005
Location: West Sussex, England
Expertise:
Software:
 
Posts: 2,829
iTrader: 21 / 100%
 

t0m is on a distinguished road

  Old

Originally Posted by theolatic View Post
try setting the div to hide in the style sheet.

visibility:hidden;
Quality lol such a simple thing

02-18-2007, 12:06 AM
#5
Zara is offline Zara
Status: Member
Join date: Apr 2006
Location:
Expertise:
Software:
 
Posts: 249
iTrader: 9 / 100%
 

Zara is on a distinguished road

  Old

I'm more of a PHP/MySQL person so bare with me on JS... I am wanting to do a similar show/hide function... Only thing is I'm doing it on a navigation list that is dynamically populated... Any suggestions?

02-18-2007, 12:43 AM
#6
Zara is offline Zara
Status: Member
Join date: Apr 2006
Location:
Expertise:
Software:
 
Posts: 249
iTrader: 9 / 100%
 

Zara is on a distinguished road

  Old

Wow, so much easier than i expected it to be. I got it working using this simple function...

Code:
 function toggleNav(obj) {
    var el = document.getElementById(obj);
    if ( el.style.display != 'none' ) {
        el.style.display = 'none';
    }
    else {
        el.style.display = '';
    }
}

02-18-2007, 10:42 AM
#7
t0m is offline t0m
Status: Request a custom title
Join date: Jan 2005
Location: West Sussex, England
Expertise:
Software:
 
Posts: 2,829
iTrader: 21 / 100%
 

t0m is on a distinguished road

  Old

Glad to see you got it working

02-18-2007, 11:03 AM
#8
localhost is offline localhost
localhost's Avatar
Status: Dediport Hosting
Join date: Jul 2006
Location: Berkshire
Expertise: programming, business
Software: Dreamweaver
 
Posts: 1,316
iTrader: 17 / 100%
 

localhost is on a distinguished road

  Old

that is pretty simple I might make a similar script soon..

Closed Thread    


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

  Posting Rules  
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump:
 
  Contains New Posts Forum Contains New Posts   Contains No New Posts Forum Contains No New Posts   A Closed Forum Forum is Closed