Welcome to our forums...

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed.

Forum Statistics

  • Forum Members:
  • Total Threads:
  • Total Posts: 2
There are 1 users currently browsing forums.
JavaScript Coding JavaScript allows rich, browser-based web-applications with interactivity and complex visual effects. For discussion on JavaScript, use this forum.

Reply
  #1  
Old 06-20-2009
pritnep's Avatar
Friendly Aussie
 
Join Date: Nov 2005
Location: Australia
Age: 21
Posts: 463
Rep Power: 5
pritnep is on a distinguished road
Cookie remembering drop down box styling

Haven't used cookies before really but I'd like to create a cookie that remembers the options a user has selected so they can have their styling next time they visit. The user selects the styles through 2 drop down boxes.

Just wondering how I would do it and asking for a bit of help.

Below are the drop down boxes for the information I would like the cookie to remember.

HTML Code:
<script type="text/javascript">
function fontsize() {
 selectedstyle = document.form1.font.selectedIndex;
 newsize = document.form1.font.options[selectedstyle].value;
 document.getElementById("userstyle").style.fontSize = newsize;
}
function fontcolour() {
 selectedstyle = document.form1.color.selectedIndex;
 newcolor = document.form1.color.options[selectedstyle].value;
 document.getElementById("userstyle").style.color = newcolor;
}
</script>
<div id="userstyle">
<body>text
<form name="form1">
   <select name="font" onChange="fontsize();">
    <option value = "16px">Normal Size</option>
    <option value = "22px">Medium Size</option>
    <option value = "26px">Large Size</option>
   </select>
   
   <select name="color" onChange="fontcolour();">
    <option value = "#ffffff">White</option>
    <option value = "#000000">Black</option>
    <option value = "#666666">Grey</option>
    <option value = "#ff0000">Red</option>
   </select>
</form>
</body>
</div>
Reply With Quote
  #2  
Old 06-20-2009
darkecho's Avatar
official undercover guy
 
Join Date: Aug 2005
Location: Michigan... USA
Age: 21
Posts: 2,596
Rep Power: 7
darkecho is on a distinguished road
Re: Cookie remembering drop down box styling

JavaScript Cookies - This should help.
Reply With Quote


Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
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

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Drop Box in Xcode machacker General Programming 6 02-07-2008 08:45 AM
Load/Minimize Box Helloadam JavaScript Coding 6 06-12-2006 09:59 AM
ASP how to create a cookie wizard General Web Programming 0 01-02-2005 09:45 AM