Reply
Remove whitespace when div is hidden
Old 07-05-2008, 07:11 PM Remove whitespace when div is hidden
Gilligan's Avatar
Dead Like Me

Posts: 1,632
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
__________________
DoThatDesign.com - Professional Website Design - FREE Quotes!
Gilligan is offline
Reply With Quote
View Public Profile
 
 
When You Register, These Ads Go Away!
Old 07-05-2008, 07:27 PM Re: Remove whitespace when div is hidden
mgraphic's Avatar
Truth Seeker

Latest Blog Post:
JAMISONTUNES
Posts: 2,578
Name: Keith Marshall
Location: West Hartford, CT
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, 06:34 AM Re: Remove whitespace when div is hidden
Gilligan's Avatar
Dead Like Me

Posts: 1,632
Name: Stefan
Location: London, UK
Trades: 0
instead of visibility="hidden" ??
__________________
DoThatDesign.com - Professional Website Design - FREE Quotes!
Gilligan is offline
Reply With Quote
View Public Profile
 
Old 07-06-2008, 10: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.09289 seconds with 13 queries