Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>There is this <strong>web page in-memory caching</strong> method that I once used before to save the whole form: <a href="https://developer.mozilla.org/en-US/docs/Using_Firefox_1.5_caching" rel="nofollow"><strong>Using_Firefox_1.5_caching</strong></a>. It caches the JavaScript states as well but there are a lot of setup you need to keep in mind to make it properly working. </p> <p>In your case, since you only want to save the <code>&lt;select&gt;</code> data only. I think using <a href="https://developer.mozilla.org/en-US/docs/Web/API/document.cookie" rel="nofollow"><strong><code>document.cookie</code></strong></a> is a good solution:</p> <pre><code>$('#category').on("change", function () { var cat = $(this).val(); var subCat = ""; switch (cat) { case "one": subCat = '&lt;option value="sub1"&gt;Sub Category One&lt;/option&gt;'; break; case "two": subCat = '&lt;option value="sub2"&gt;Sub Category Two&lt;/option&gt;'; break; } setCookie('select', cat); $("#subcategory").html(subCat); }) var sel = getCookie('select'); if (sel) { /* if cookie key 'select' is set change the '#category' selected value and trigger the change() event.*/ $('#category').val(sel).trigger('change'); } //Cookie functions for setting and retrieving, the duration I set is 24hrs only. function setCookie(key, value) { var expires = new Date(); expires.setTime(expires.getTime() + (1 * 24 * 60 * 60 * 1000)); document.cookie = key + '=' + value + ';expires=' + expires.toUTCString(); } function getCookie(key) { var key = document.cookie.match('(^|;) ?' + key + '=([^;]*)(;|$)'); return key ? key[2] : null; } </code></pre> <p>See this <a href="http://jsfiddle.net/Dz98T/3/" rel="nofollow"><strong>jsfiddle</strong></a>.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload