SitePoint Sponsor

User Tag List

Results 1 to 8 of 8

Thread: Remember Array

  1. #1
    SitePoint Guru
    Join Date
    Sep 2001
    Location
    Vancouver
    Posts
    809
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Arrow Remember Array

    Hi,

    I'm no JavaScript wiz, so I don't really know if what I'm asking will make any sense to anyone. I was testing out this script that a friend made for me.

    It's like this: It collapses and expands certain information in a little window. Similiar to the script Microsoft has on their web site (or had, I don't know if they still do, I saw it a long time ago).

    There are several arrays in the script. When a person collapses one of them, and doesn't expand it back, is it possible to remember that, so the next time they visit it will still be collapsed.

    Below is the line where the arrays are, like I said, I don't know if this will help, but I don't want to post the whole script. It took my friend about a week to make it work.

    var arrParts = new Array("HPFrameHL", "HPFrameDL", "HPFrameEL", "HPFrameGL", "HPFrameNL",
    Any help would be greatly appreciated! E-mail me at darin23@shaw.ca if you would like to get a closer look at the script.

  2. #2
    SitePoint Wizard geiger's Avatar
    Join Date
    Jul 2001
    Posts
    2,459
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Set a cookie with the variable.

  3. #3
    SitePoint Guru
    Join Date
    Sep 2001
    Location
    Vancouver
    Posts
    809
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    My web site is written in PHP. Should I use PHP or JavaScript to set the cookie?

  4. #4
    SitePoint Wizard geiger's Avatar
    Join Date
    Jul 2001
    Posts
    2,459
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    PHP. Put:
    PHP Code:
    <?php
    setcookie
    ("yourvariable","$yourvariable");
    ?>
    Right on the top of the page after you get the variable. No information can get to the browser before that.

  5. #5
    SitePoint Guru
    Join Date
    Sep 2001
    Location
    Vancouver
    Posts
    809
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Nope, PHP doesn't work. What I'm trying to do, is once someone collapses one of the windows, the next time they come back, the window to still be collapsed. Same thing for all the windows.
    Last edited by Darin; Jul 17, 2002 at 22:49.

  6. #6
    SitePoint Wizard geiger's Avatar
    Join Date
    Jul 2001
    Posts
    2,459
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    No time now. Sorry

  7. #7
    SitePoint Guru
    Join Date
    Sep 2001
    Location
    Vancouver
    Posts
    809
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    It's okay. Could someone who knows JavaScript very well check it out and help me out?

  8. #8
    Perl/Mason Guru Flawless_koder's Avatar
    Join Date
    Feb 2002
    Location
    Gatwick, UK
    Posts
    1,206
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Well just do this:

    The windows names in the array are sequential.

    So just store a binary figure in a cookie which will used to work out which to open and close.

    Onload check for the cookie value - if it's there then split around nothing and loop - setting the state of the windows as needed.

    Flawless
    ---=| If you're going to buy a pet - get a Shetland Giraffe |=---


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
  •