CodeGuru Forums -
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic Newsletters VB Forums Developer.com


Newest CodeGuru.com Articles:

  • Installing SQL Server 2008
  • Writing UDFs for Firebird Embedded SQL Server
  • [Updated] Shutdown Manager
  • Building Windows Azure Cloud Service Applications with Azure Storage and the Azure SDK

  • Search CodeGuru:
     



    Go Back   CodeGuru Forums > Other Programming > Scripting - Client Side
    FAQ Members List Calendar Search Today's Posts Mark Forums Read

    Scripting - Client Side Discuss client-side scripting issues. Client-side scripting such as JavaScript, JScript, and VBScript as well as technologies such as HTML and stylesheets.

    Reply
     
    Thread Tools Search this Thread Rating: Thread Rating: 1 votes, 5.00 average. Display Modes
      #1    
    Old May 20th, 2002, 04:14 PM
    mach15 mach15 is offline
    Junior Member
     
    Join Date: Jul 2001
    Location: Brasil
    Posts: 11
    mach15 is an unknown quantity at this point (<10)
    HTML div tag visibility problem

    Hi !

    I have a problem with the HTML page below:

    <html>
    <script language="JavaScript">
    function setVisibility(id, visibility) {
    document.all[id].style.visibility = visibility;
    if (visibility == "hidden") {
    document.all[id].style.position = "absolute";
    }
    else if (visibility == "visible") {
    document.all[id].style.position = "relative";
    }
    }

    function setParentVisibility(id, visibility) {
    parent.document.all[id].style.visibility = visibility;
    if (visibility == "hidden") {
    parent.document.all[id].style.position = "absolute";
    }
    else if (visibility == "visible") {
    parent.document.all[id].style.position = "relative";
    }
    }
    </script>
    <body>
    <form name="Teste">
    <div id="main" style="visibility:visible; position:relative">
    Main
    <input value="switch" type="button" onClick="setVisibility('main', 'hidden');setVisibility('sub', 'visible');">
    </div>
    <div id="sub" style="visibility:hidden; position:absolute">
    Sub
    <input value="switch" type="button" onClick="setVisibility('main', 'visible');setVisibility('sub', 'hidden');">
    </div>
    </form>
    </body>
    </html>

    When I press the 'switch' button in the 'main' div layer, the 'main' div layer stays hidden and the 'sub' div layer is shown.
    When I press the 'switch' button in the 'sub' div layer, the 'sub' div layer stays hidden and the 'main' div layer is shown.
    The problem is when the layer to be displayed is shown, because the button of the layer do not appear directly. You have to resize the browser's window to view the button. How can I solve this problem ??

    thanks,

    mach15
    Reply With Quote
      #2    
    Old May 21st, 2002, 02:30 PM
    SButler SButler is offline
    Junior Member
     
    Join Date: Dec 2000
    Posts: 15
    SButler is an unknown quantity at this point (<10)
    I believe you might want to just have a single "DIV" tag whose InnerHTML property changes with the click of a button. I also have the same issues you are having. I think it would be much more straightforward to just change your display rather than adjusting positions of your display.
    Reply With Quote
      #3    
    Old May 22nd, 2002, 07:42 PM
    ChrisWoyton ChrisWoyton is offline
    Junior Member
     
    Join Date: May 2002
    Posts: 3
    ChrisWoyton is an unknown quantity at this point (<10)
    Mach,

    You could just use the display property (instead of visibility) which doesn't allot space on the page when the display is set to "none".

    Here's a rewrite which does what I think you want to do:

    <html>
    <script language="JavaScript">
    function setVisibility(id, visibility) {
    document.all[id].style.display = visibility;
    }

    </script>
    <body>
    <form name="Teste">
    <div id="main" style="display:block">
    Main
    <input value="switch" type="button" onClick="setVisibility('main', 'none');setVisibility('sub', 'inline');">
    </div>
    <div id="sub" style="display:none">
    Sub
    <input value="switch" type="button" onClick="setVisibility('main', 'inline');setVisibility('sub', 'none');">
    </div>
    </form>
    </body>
    </html>

    Hope this helps,

    Chris
    Reply With Quote
    Reply

    Bookmarks
    Go Back   CodeGuru Forums > Other Programming > Scripting - Client Side


    Thread Tools Search this Thread
    Search this Thread:

    Advanced Search
    Display Modes 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 -5. The time now is 09:34 AM.



    Acceptable Use Policy

    internet.comMediabistrojusttechjobs.comGraphics.com

    WebMediaBrands Corporate Info


    Advertise | Newsletters | Feedback | Submit News

    Legal Notices | Licensing | Permissions | Privacy Policy


    Powered by vBulletin® Version 3.7.3
    Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
    Copyright WebMediaBrands Inc. 2002-2009