Create and read cookie in drop down menu with javascript
<p>I'm using this HTML code:</p>

<pre><code>&lt;head&gt;

&lt;link href="defualt.css" rel="stylesheet" type="text/css" /&gt;
&lt;link href="theme1.css" title="theme1" rel="alternate stylesheet" type="text/css" /&gt;
&lt;link href="theme2.css" title="theme2" rel="alternate stylesheet" type="text/css" /&gt;
&lt;link href="theme3.css" title="theme3" rel="alternate stylesheet" type="text/css"  /&gt;

&lt;script type="text/javascript" src="javascript.js"&gt;&lt;/script&gt;

&lt;/head&gt;
&lt;body&gt;

&lt;form&gt;
    &lt;select id="myList" &gt;
        &lt;option value="default"&gt;Default&lt;/option&gt;
        &lt;option value="theme1"&gt;Theme 1&lt;/option&gt;
        &lt;option value="theme2"&gt;Theme 2&lt;/option&gt;  
        &lt;option value="theme3"&gt;Theme 3&lt;/option&gt;
    &lt;/select&gt;
&lt;/form&gt;

&lt;/body&gt;
</code></pre>

<p>It's a form to change style sheets. This is the javascript I'm using:</p>

<pre><code>function setActiveStyleSheet(title) {
  var i, a, main;
  for(i=0; (a = document.getElementsByTagName("link")[i]); i++) {
    if(a.getAttribute("rel").indexOf("style") != -1 &amp;&amp; a.getAttribute("title")) {
      a.disabled = true;
      if(a.getAttribute("title") == title) a.disabled = false;
    }
  } 
  createCookie("style", title, 7);
}

function getActiveStyleSheet() {
  var i, a;
  for(i=0; (a = document.getElementsByTagName("link")[i]); i++) {
    if(a.getAttribute("rel").indexOf("style") != -1 &amp;&amp; a.getAttribute("title") &amp;&amp; !a.disabled) return a.getAttribute("title");
  }
  return null;
}

function getPreferredStyleSheet() {
  var i, a;
  for(i=0; (a = document.getElementsByTagName("link")[i]); i++) {
    if(a.getAttribute("rel").indexOf("style") != -1
       &amp;&amp; a.getAttribute("rel").indexOf("alt") == -1
       &amp;&amp; a.getAttribute("title")
       ) return a.getAttribute("title");
  }
  return null;
}

function createCookie(name,value,days) {
  if (days) {
    var date = new Date();
    date.setTime(date.getTime()+(days*24*60*60*1000));
    var expires = "; expires="+date.toGMTString();
  }
  else expires = "";
  document.cookie = name+"="+value+expires+"; path=/";
}

function readCookie(name) {
  var nameEQ = name + "=";
  var ca = document.cookie.split(';');
  for(var i=0;i &lt; ca.length;i++) {
    var c = ca[i];
    while (c.charAt(0)==' ') c = c.substring(1,c.length);
    if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
  }
  return null;
}

window.onload = function(e) {
  var cookie = readCookie("style");
  var title = cookie ? cookie : getPreferredStyleSheet();
  setActiveStyleSheet(title);
}

var cookie = readCookie("style");
var title = cookie ? cookie : getPreferredStyleSheet();
setActiveStyleSheet(title);


function initate()
{

document.getElementById("myList").onchange = function() {
   setActiveStyleSheet(this.value);
   return false
};

}

window.onload = initate;
</code></pre>

<p>The changing of the style sheets work great but I want the option chosen in the menu to stay after I reload the page. This works as it should in Firefox but not in Chrome. I'm quite new to javascripts and I haven't written all of this code myself so I don't fully understand all of it. Is it possible to save the chosen option of the menu in the same cookie or is it better/easier to create a new one?</p>
