Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

JavaScript Forum


You are currently viewing our JavaScript Forum as a guest. Please register to participate.
Login



Reply
Remove whitespace when div is hidden
Old 07-05-2008, 08:11 PM Remove whitespace when div is hidden
Gilligan's Avatar
Website Designer

Posts: 1,670
Name: Stefan
Location: London, UK
Trades: 0
Code:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>

<script>

function multipart(){
if(document["form"]["input"].checked){
document.getElementById("parts").style.visibility="visible"
}
else{
document.getElementById("parts").style.visibility="hidden"
}
}
//-->
</script>
</head>

<body onload="toggleTextBox(false)">
<form method="post" action="editor.php" name="form">
                        
      &lt;?php echo $linkname ?&gt; Address: 
        <input type="text" name="textfield" id="textfield" />
  <input type="checkbox" name="input" value="ON" onclick="multipart()"> Multi Parts?
       <br /><br />
              
  <div id="parts" style="visibility:hidden">
                      Part 2: <input type="text" /><br />
                    Part 3: <input type="text" /><br />
                    Part 4: <input type="text" /><br />
                    Part 5: <input type="text" /><br />
                    Part 6: <input type="text" /><br />
                    Part 7: <input type="text" /><br />
                    
  </div>   
              <br />
              <input type="submit" value="Submit" />
                      
</form>              
                         
</body>
</html>
This shows the div "parts" when the checkbox is checked, and hides when unchecked. however when unchecked there's a whitespace the size of the div contents. How can I remove this?

Thanks
__________________

Please login or register to view this content. Registration is FREE
Gilligan is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 07-05-2008, 08:27 PM Re: Remove whitespace when div is hidden
mgraphic's Avatar
Truth Seeker

Latest Blog Post:
JAMISONTUNES
Posts: 2,898
Name: Keith Marshall
Location: Connecticut
Trades: 0
I always use the display style.

style.display='none'; // hide

style.display=''; // normal
__________________

<mgraphic /> - I don't have a solution but I admire the problem.
mgraphic is offline
Reply With Quote
View Public Profile
 
Old 07-06-2008, 07:34 AM Re: Remove whitespace when div is hidden
Gilligan's Avatar
Website Designer

Posts: 1,670
Name: Stefan
Location: London, UK
Trades: 0
instead of visibility="hidden" ??
__________________

Please login or register to view this content. Registration is FREE
Gilligan is offline
Reply With Quote
View Public Profile
 
Old 07-06-2008, 11:51 AM Re: Remove whitespace when div is hidden
Skilled Talker

Posts: 71
Trades: 0
Quote:
Originally Posted by Gilligan View Post
instead of visibility="hidden" ??
Visibility:hidden; removes the element visually, however it remains there.

Display:none; removes the element visually, and also "deletes" it from the page.
CrazeDizzleD is offline
Reply With Quote
View Public Profile
 
Reply     « Reply to Remove whitespace when div is hidden
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

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





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.90837 seconds with 12 queries