Current location: Hot Scripts Forums » General Web Coding » JavaScript » cookies


cookies

Reply
  #1 (permalink)  
Old 12-05-04, 04:59 AM
misterman misterman is offline
Newbie Coder
 
Join Date: Jun 2004
Posts: 18
Thanks: 0
Thanked 0 Times in 0 Posts
cookies

hi there,

i got the following problem:
i use cookies to remember that menu's are collapsed.
but now it places the cookies but i don't know how to call them......
the is the script i use for the collapsing:
Code:
function collapse(v) {
  var expireDate = new Date;
  expireDate.setDate(expireDate.getDate( ) + 365);

  e = document.getElementById(v);
  if (e.style.display == '') {
    e.style.display = 'none';
    document.cookie = 'mistermansclickercollapse[' + v + ']=1; expires=' + expireDate.toGMTString( ) + ';';
  } else {
    e.style.display = '';
    document.cookie = 'mistermansclickercollapse[' + v + ']=0;';
  }
  return false;
}
now and this is the code where in i called the collapse function:
Code:
<div class="infobox">
  <p class="left"><a href="#" onclick="return collapse('clicker');">&raquo; Misterman's Clicker: Home </a></p>

	<p><a href="news.php">News</a></p>
	<div id="clicker">
i hope this is enough info. I would be glad if you helped....

regards, misterman
Reply With Quote
  #2 (permalink)  
Old 12-07-04, 02:49 AM
TwoD TwoD is offline
Community VIP
 
Join Date: Sep 2003
Location: 404
Posts: 1,813
Thanks: 0
Thanked 0 Times in 0 Posts
To read a cookie you simply do alert(document.cookie) or myCookie=document.cookie.
However, according to this: 'mistermansclickercollapse[' + v + ']=1', it looks like you are using an array to remember if a menu is collapsed or not.
It might get slightly tricky to read that data and import it.
I don't want to make a guess at how the rest of the code works in case I lead you in the wrong direction.
Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

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
Trackbacks are On
Pingbacks are On
Refbacks are On

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
SeSSIon Use Cookies Klesti PHP 6 09-29-04 09:08 AM
Please help seeting and reading cookies... Eclipse PHP 1 06-03-04 05:01 PM
cookies....how do I use them?? cwg25 HTML/XHTML/XML 5 03-05-04 10:25 AM
Delete cookies regardless of case. AussierulesOK JavaScript 1 11-08-03 10:15 AM
Can't seem to get the cookies to the cookie_jar benny666 Perl 1 10-28-03 04:54 AM


All times are GMT -5. The time now is 10:36 PM.
vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.