www.webdeveloper.com
Recent Articles
  • Finding Slow Running Queries in ASE 15
  • A More Advanced Pie Chart for Analysis Services Data
  • Adobe AIR Programming Unleashed: Working with Windows
  • Performance Testing SQL Server 2008's Change Data Capture Functionality
  • The ABC's of PHP: Introduction to PHP
  • How to Migrate from BasicFiles to SecureFiles Storage
  • Why the Twitter Haters Are Wrong
  • User Personalization with PHP: Beginning the Application
  • Whats in an Oracle Schema?
  • Lighting Enhancement in Photoshop
  •  

    Go Back   WebDeveloper.com > Client-Side Development > JavaScript

    JavaScript JavaScript (not Java) Discussion and technical support, including AJAX and frameworks (JQuery, MooTools, Prototype...)

    Reply
     
    Thread Tools Search this Thread Rate Thread Display Modes
      #1  
    Old 11-22-2002, 12:44 PM
    screamingbuddha screamingbuddha is offline
    Registered User
     
    Join Date: Nov 2002
    Posts: 13
    resolved [RESOLVED] visible/invisible div's

    could use some help here, sorry to have to ask for this kind of load

    I have 2 elements that will be displayed on a page depending on a cookie status.
    One element is a form, the other is a table structure.

    I haven't used DHTML in some time, and I remember that you could use z-index to determine which one would be displayed - in this case:

    var Status == getCookieValue(myCookie)
    if Status = "taken"
    {
    /* table containing results, information, etc.. */
    }
    else
    {
    /* form and submit button */

    I don't think z-index is still the most effecient, or easiest way to do this.. is there a more current method?
    __________________
    ____
    n00b

    Last edited by screamingbuddha; 11-25-2002 at 09:56 AM.
    Reply With Quote
      #2  
    Old 11-22-2002, 12:46 PM
    Zach Elfers Zach Elfers is offline
    Registered User
     
    Join Date: Nov 2002
    Posts: 631
    I don't know what you mean, but you can hide divs etc., but putting display:none; in the CSS script.
    Reply With Quote
      #3  
    Old 11-22-2002, 12:58 PM
    gil davis's Avatar
    gil davis gil davis is offline
    Nobody important
     
    Join Date: Nov 2002
    Posts: 4,434
    The "z-index" parameter detemines the stacking order of positioned objects that are overlapping. It is used to bring an object to the front of another object without changing the visibility of either object.

    The "display" parameter detemines how an object is displayed in the flow of the document: "inline", "block" or "none". It is used to expand and collapse things, like an outline or menu.

    The "visiblilty" parameter determies whether an object is visible or not: "visible", "hidden" or "inherit". It is used to selectively show and hide portions of a document.
    Reply With Quote
      #4  
    Old 11-22-2002, 01:13 PM
    screamingbuddha screamingbuddha is offline
    Registered User
     
    Join Date: Nov 2002
    Posts: 13
    ok I think I understand a little better..
    can you help me write it out, or point to an example?
    (I know my syntax is bad.. corrections and flames welcome)


    var Status == getCookieValue(myCookie)
    if Status = "taken";
    {
    (id=Poll style="visibility: hidden")
    (id=Results style="visibility: visible")
    }
    else
    {
    (id=Poll style="visibility: visible")
    (id=Results style="visibility: hidden")
    }

    <body>

    <table><tr>

    <div id="Poll">
    <td>poll</td>
    <td>info</td>
    <td>submit</td>
    </div>

    </tr><tr>

    <div id="Results">
    <td>results</td>
    <td>info</td>
    </div>

    </tr></table>

    this is the nature of what I have to produce.. sorry I'm no good at this
    __________________
    ____
    n00b
    Reply With Quote
      #5  
    Old 11-22-2002, 01:33 PM
    gil davis's Avatar
    gil davis gil davis is offline
    Nobody important
     
    Join Date: Nov 2002
    Posts: 4,434
    Quote:
    Originally posted by screamingbuddha
    (id=Poll style="visibility: hidden")
    (id=Results style="visibility: visible")
    Code:
    {document.getElementById("Poll").style.visibility = "hidden";
     document.getElementById("Rusults").style.visibility = "visible";}
    You should be able to figure out the rest.
    Reply With Quote
      #6  
    Old 11-22-2002, 01:59 PM
    screamingbuddha screamingbuddha is offline
    Registered User
     
    Join Date: Nov 2002
    Posts: 13
    Gil you think too highly of me..
    can I get a code check
    here where I'm testing this?

    thanks
    __________________
    ____
    n00b
    Reply With Quote
      #7  
    Old 11-22-2002, 02:35 PM
    gil davis's Avatar
    gil davis gil davis is offline
    Nobody important
     
    Join Date: Nov 2002
    Posts: 4,434
    My best advice would be to get a working cookie script. Yours isn't.
    Reply With Quote
      #8  
    Old 11-22-2002, 02:42 PM
    screamingbuddha screamingbuddha is offline
    Registered User
     
    Join Date: Nov 2002
    Posts: 13
    I'd been working with this script previously.. and it seemed to work just fine (commented out what I added, and it didn't show any errors)
    what platform/browser are you running?
    __________________
    ____
    n00b
    Reply With Quote
      #9  
    Old 11-22-2002, 04:28 PM
    gil davis's Avatar
    gil davis gil davis is offline
    Nobody important
     
    Join Date: Nov 2002
    Posts: 4,434
    (heavy sigh)

    I used IE 5.5 on Windows 2000.

    Your getCookieValue() function does not seem to return the cookie correctly. I couldn't debug the page any further, and gave up. Perhaps someone with more patience with cookie scripts and such will pick up this thread.
    Reply With Quote
      #10  
    Old 11-22-2002, 05:18 PM
    screamingbuddha screamingbuddha is offline
    Registered User
     
    Join Date: Nov 2002
    Posts: 13
    (shaking my head in shame)

    I'm sorry Gil, I'm new here and certainly didn't mean to cause such a reaction within days of registering..

    for anyone else with patience remaining.. I've updated the cookieScript to something seemingly more stable.
    The original problem still remains, I need only one of the div's visible based on the conditional.
    here
    __________________
    ____
    n00b
    Reply With Quote
      #11  
    Old 11-22-2002, 06:01 PM
    gil davis's Avatar
    gil davis gil davis is offline
    Nobody important
     
    Join Date: Nov 2002
    Posts: 4,434
    Well, I looked at your latest, and you have cleaned up the cookie crumbs.

    I can now see your logic problems.

    You cannot change the visibility of an object until it exists. You need to make both divs "hidden" by default. Then in an "onLoad" script, act accordingly.

    Add the visible decisions to the existing "onLoad" script. This stuff:

    Quote:
    <script language="javascript">
    GetCookie('pollStatus')
    {
    if (GetCookie('pollStatus') == null)
    {
    SetCookie('pollStatus','untaken', exp);
    }
    if (GetCookie('pollStatus') == 'untaken')
    {
    //document.getElementById("pollResults").style.visibility = "hidden";
    //document.getElementById("pollQuestion").style.visibility = "visible";
    }
    else
    {
    //document.getElementById("pollQuestion").style.visibility = "hidden";
    //document.getElementById("pollResults").style.visibility = "visible";
    }
    }
    </script>
    Put it in a function and get rid of the first cookie call (not necessary, doesn't do anything) and the first set of braces. Call the function somewhere in the "onLoad".

    Change the "div" styles, either inline or using a style sheet. For example (using the ID's so you can change the type of tag if you want):

    Quote:
    <style>
    .pollQuestion {visibility: hidden}
    .pollResults {visibility: hidden}
    </style>
    Reply With Quote
      #12  
    Old 11-22-2002, 08:36 PM
    screamingbuddha screamingbuddha is offline
    Registered User
     
    Join Date: Nov 2002
    Posts: 13
    thanks very much!
    (labor fruits updated)

    sb
    __________________
    ____
    n00b
    Reply With Quote
      #13  
    Old 08-19-2003, 11:02 PM
    conma2cang conma2cang is offline
    Registered User
     
    Join Date: Aug 2003
    Posts: 2
    i want to use onclick to show/hide tables...

    but i want the setting show/hide to be remembered .. so that when the user reloads the page... the setting is still there...


    how do i use the codes above then?

    plz explain to me a little more!

    thx
    Reply With Quote
    Reply

    Bookmarks


    Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
     
    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 Off
    HTML code is Off
    Forum Jump


    All times are GMT -5. The time now is 07:38 PM.



    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.