SitePoint Sponsor

User Tag List

Results 1 to 4 of 4
  1. #1
    SitePoint Enthusiast
    Join Date
    Dec 2006
    Posts
    61
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Show / Hide Messages script ** NEED HELP **

    Hello.

    What i am trying to do on my website is to have a message box that apprears when a user logs into my website. I alctually have this working now, i have a little close icon, and when this is clicked the message box vanishes. My problem is when the page is refreshed the box comes back .... but i dont want it to. Idealy i want it to work similar to a php session .... that for the time the user has the browser window open or they are logged into my site ... if they have closed the message box ... it does NOT return. When the user next logs into the site the message will re-appear.

    Here is a pic of what i have right now :-



    And here is my code so far

    Code:
    <script type="text/javascript">
    <!--
    function ShowHide(id) {
    obj = document.getElementsByTagName("ul");
    if (obj[id].style.visibility == 'hidden'){
    obj[id].style.visibility = 'visible';
    obj[id].style.height = 'auto';
    }
    else {
    obj[id].style.visibility = 'hidden';
    obj[id].style.display = 'none';
    }
    }
    //-->
    </script>
    Thats the javascript that i use, and here is my message box code :

    PHP Code:

    <?php

    echo '<ul id="lay1" class="Notice"><li>';
            
    echo 
    'Welcome, new to this website ? why not head over to our <a href="/Forums/index.php">Forums</a> and introduce yourself.';
            
            
    echo 
    '';?><span class="rightnotice"><a href="javascript:ShowHide('lay1')" class="NoticeRemove">&nbsp;</a><?php echo '</span></li></ul>';

    }
             
    ?>
    Is there anyway that once the box is clicked i can register a php session that i can check if its being set or not .. if it has then the box will not show .. but if the session is not set the box will show ??

    I hope i was clear enough on this

    Thanks in advance
    Chris
    Want quality photoshop tutorials : Tutorial Zone

  2. #2
    Programming Team silver trophybronze trophy
    Mittineague's Avatar
    Join Date
    Jul 2005
    Location
    West Springfield, Massachusetts
    Posts
    17,137
    Mentioned
    190 Post(s)
    Tagged
    2 Thread(s)

    remember

    There might be a way to do this with server-side SESSIONs, but since this is client-side javascript I think using COOKIEs might be better no?

  3. #3
    SitePoint Enthusiast
    Join Date
    Dec 2006
    Posts
    61
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    humm good point i did not think about cookies .... how would i go about implementing this then ? Any help would be greatle appreciated.
    Want quality photoshop tutorials : Tutorial Zone

  4. #4
    SitePoint Wizard siteguru's Avatar
    Join Date
    Oct 2002
    Location
    Scotland
    Posts
    3,629
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    Ian Anderson
    www.siteguru.co.uk


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •