SitePoint Sponsor

User Tag List

Results 1 to 4 of 4
  1. #1
    SitePoint Addict swaraj_here's Avatar
    Join Date
    Jan 2007
    Location
    India
    Posts
    224
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Question javascript restoring value

    I have a toggle button inside each page. That toggle button actually toggles left panel of my design. What I need is that when the left panel gets off by toggling button then it should remain of all across the pages I visit until and unless I again click the toggle button.

    So for that I think I have to set a mechanism to send some variable value through that toggling button, which is now functioning through a Java Script.

    So that the page can track that variable value and will be able to follow the previous toggling status.

    What can be the solution, please guide me, if anyone of you have proper solution with example.

  2. #2
    SitePoint Guru
    Join Date
    Apr 2006
    Posts
    802
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    The only pure javascript way to save data between pages is to use cookies,
    and read them when you open each page on your site.

    If you use server scripting (php, asp) sessions may be more robust

  3. #3
    SitePoint Addict swaraj_here's Avatar
    Join Date
    Jan 2007
    Location
    India
    Posts
    224
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by mrhoo View Post
    The only pure javascript way to save data between pages is to use cookies,
    and read them when you open each page on your site.

    If you use server scripting (php, asp) sessions may be more robust

    So can you please show me an example..........

  4. #4
    SitePoint Addict mmanders's Avatar
    Join Date
    Jul 2006
    Location
    Edinburgh, Scotland
    Posts
    358
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    If the user has toggled the the bar (presumably by invoking a function), then you could add a PHP session variable, i.e. $_SESSION['isBarEnabled'] = false;

    You could then check the value of $_SESSION['isBarEnabled'], if it is set to true, then toggle the bar on and if it is set to false, toggle the bar off using your javascript function.


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
  •