SunQuest
 
           JavaScript Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
User Name:
Password:
Remember me
 
Go Back   Dev Articles Community ForumsProgrammingJavaScript Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Display Modes
 
Unread Dev Articles Community Forums Sponsor:
Stop making mediocre tutorials.The best tutorials are video! Camtasia Studio makes it easy to create engaging, buzz-building screen videos at any size, in any popular format. Download the free trial!
  #1  
Old May 5th, 2004, 01:21 PM
normpeterson normpeterson is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: May 2004
Posts: 1 normpeterson User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Help with keeping cookies please.

Hello everyone. I have a script that works fine. The only problem is that the cookies do not stay. The user picks a color, and then the background color changes. When the user comes back to the page, it is supposed to keep that color, but does not. Is there a function I can add to do this, or modify what I already have? I would like to keep the layout as
I have it if possible with using the button.Thanks for the help! Norman.
Code:
<script>
function setCookie()
  {  
      var expiresDate = new Date();
      expiresDate.setFullYear(expiresDate.getFullYear() + 1);   
      document.cookie = encodeURI("setCookie=" 
          + document.colorchoice.selection.value)+ "; expires = "+ expiresDate.
toUTCString(); 
     
     alert("Your background color has been saved for your next visit to this page");
}
  
 
function colorit() {
   var Color  = parseInt(document.colorchoice.selection.selectedIn  dex)
   changeColor(Color)
}

var colorlist = new Array("red","blue","yellow")
function changeColor(color) {
     document.bgColor = colorlist[color] 
  document.colorchoice.value = colorlist[color]
}
</script>
</head>
<body>
<form name="colorchoice">
<p> <h2>Click button to pick color.</h2></p>
<SELECT NAME="selection" value="selectedIndex">
<OPTION>Red
<OPTION>Blue
<OPTION>Yellow
</SELECT>
<INPUT TYPE="button" NAME="Change_Color" VALUE="Change Color"   onClick="colorit(); 
setCookie();"></form>
</body>
</html>

Reply With Quote
Reply

Viewing: Dev Articles Community ForumsProgrammingJavaScript Development > Help with keeping cookies please.


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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 6 hosted by Hostway