title: save selector in cookie and get that cookie back
body: <p>I want to ask the user in my webapp with a drop-down menu which school website they want to open, then save that in a cookie and automatically open that website next time they open the webapp. I'm not good at JS so please explain.</p>
  
  <p>Thank's in advance.</p>
  
  <pre><code>&lt;head&gt;
  &lt;script&gt;
   &lt;!-- Cookie script --&gt;
  &lt;/script&gt;
  &lt;/head&gt;
  &lt;body&gt;
      &lt;form&gt;
          &lt;select id="class"&gt;
            &lt;option value="Choose"&gt;Choose&lt;/option&gt;
            &lt;option value="flah"&gt;School#1&lt;/option&gt; &lt;!-- Should redirect to site #1 --&gt;
            &lt;option value="june"&gt;School#2&lt;/option&gt; &lt;!-- Should redirect to site #2 --&gt;
          &lt;/select&gt;
          &lt;button type="submit"&gt;V&amp;auml;lj&lt;/button&gt;
      &lt;/form&gt;
  &lt;/body&gt;
  </code></pre>
  
  <p></p>
  
  <p>Update:</p>
  
  <p>
      &lt;</p>
  
  <pre><code>form&gt;
          &lt;select id="class"&gt;
            &lt;option value="Choose"&gt;Choose&lt;/option&gt;
            &lt;option value="flah"&gt;School#1&lt;/option&gt; &lt;!-- Should redirect to site #1 --&gt;
            &lt;option value="june"&gt;School#2&lt;/option&gt; &lt;!-- Should redirect to site #2 --&gt;
          &lt;/select&gt;
          &lt;button type="submit" onclick="setCookie()"&gt;V&amp;auml;lj&lt;/button&gt;
      &lt;/form&gt;
  
  &lt;script type="text/javascript" language="javascript"&gt;    
      function setCookie(cookiename, cookievalue, cookieexdays) {
          var d = new Date();
          d.setTime(d.getTime() + (cookieexdays*24*60*60*1000));
          var expires = "expires="+d.toUTCString();
          document.cookie = cookiename+ "=" + cookievalue+ "; " + expires;
      }
  
      function getCookie(cookiename) {
          var name = cookiename+ "=";
          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);
              if (c.indexOf(name) == 0) return c.substring(name.length, c.length);
          }
          return "";
      }
  
      function checkCookie() {
          var school = getCookie("SelectedSchool");
          if (school!= "") {
              //redirect to user to link
              alert("Welcome to the " + school);
          } else {
              user = prompt("Please choose your name:", "");
              if (school != "" &amp;&amp; school != null) {
                  setCookie("SelectedSchool", school, 365);
              }
          }
      }
  &lt;/script&gt;
  </code></pre>
  
  <p></p>