Go Back   CodingForums.com > :: Client side development > JavaScript programming

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 06-20-2002, 10:29 PM   PM User | #1
snakedevil1
New Coder

 
Join Date: Jun 2002
Posts: 78
Thanks: 0
Thanked 0 Times in 0 Posts
snakedevil1 is an unknown quantity at this point
hiding or viewing stuff

i want to hide or view something ( a div perhaps). could somebody write or give me a script to do this?
__________________
Computers are simple for the complex mind, yet complex for the simple mind
snakedevil1 is offline   Reply With Quote
Old 06-20-2002, 10:52 PM   PM User | #2
x_goose_x
Regular Coder

 
Join Date: Jun 2002
Location: Montreal, Canada
Posts: 644
Thanks: 0
Thanked 0 Times in 0 Posts
x_goose_x is an unknown quantity at this point
You can use:
style="display:none;

if you want 2 buttons, one that shows, one that hides:

<script>
function showhide(divname,disp) {
document.getElementById(divname).style.display=disp;
}
</script>

<a href="javascript: showhide('mydiv','none');">HIDE</a>
<a href="javascript: showhide('mydiv','');">SHOW</a>
<div id="mydiv">This is the div I wish to show/hide.</div>

Or if you want only one button

<script>
function showhide(divname) {
if (document.getElementById(divname).style.display=="") {
document.getElementById(divname).style.display="none";
}
else if (document.getElementById(divname).style.display=="none"){
document.getElementById(divname).style.display="";
}
}
</script>

<a href="javascript: showhide('mydiv');">SHOW/HIDE</a>
<div id="mydiv" style="display:;">This is the div I wish to show/hide.</div>

Also if you want the same as the previous, but to change the word of the link:

<script>
function showhide(divname,what) {
if (document.getElementById(divname).style.display=="") {
document.getElementById(divname).style.display="none";
}
else if (document.getElementById(divname).style.display=="none"){
document.getElementById(divname).style.display="";
}
if (document.getElementById(what).innerHTML=="HIDE") {
document.getElementById(what).innerHTML="SHOW";
}
else if (document.getElementById(what).innerHTML=="SHOW"){
document.getElementById(what).innerHTML="HIDE";
}
}
</script>

<span onclick="showhide('mydiv','hs');" id="hs">HIDE</span>
<div id="mydiv" style="display:;">This is the div I wish to show/hide.</div>
x_goose_x is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

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

Forum Jump


All times are GMT +1. The time now is 08:59 AM.


Advertisement
Log in to turn off these ads.