Make one div visible and another invisible

136,436

Solution 1

Making it invisible with visibility still makes it use up space. Rather try set the display to none to make it invisible, and then set the display to block to make it visible.

Solution 2

You can use the display property of style. Intialy set the result section style as

style = "display:none"

Then the div will not be visible and there won't be any white space.

Once the search results are being populated change the display property using the java script like

document.getElementById("someObj").style.display = "block"

Using java script you can make the div invisible

document.getElementById("someObj").style.display = "none"

Solution 3

I don't think that you really want an iframe, do you?

Unless you're doing something weird, you should be getting your results back as JSON or (in the worst case) XML, right?

For your white box / extra space issue, try

style="display: none;"

instead of

style="visibility: hidden;"
Share:
136,436

Related videos on Youtube

mattgcon
Author by

mattgcon

Updated on July 09, 2022

Comments

  • mattgcon
    mattgcon almost 2 years

    I have two div tags, one is for the search and the other is for the results. What I need is for when the submit button is clicked the results are returned and placed into the results div (with an iframe) and the search div should become hidden and the results div should be made visible.

    search div is initially set to visible (using the visibility to visible) and the results div is initially set to hidden (using the visibility to hidden).

    Also, initially ther eis a huge white space at the bottom of the page where the hidden div is, so how do I make sure there is no extra white space at the bottom too.

  • mattgcon
    mattgcon over 13 years
    yes actually I do, well I dont WANT one but it is required by the client
  • coolaj86
    coolaj86 over 13 years
    Correct me if I'm wrong, but with an iFrame you MUST make it visible and displayed or else some browsers won't load the content for security reasons. However, you can make it 1x1px and opacity 0.01%. I ran into this problem once before with a cross-site upload widget.