javascript - JQuery Cascade plugin to remember last selected state -


i'm using jquery cascade plugin (here)

i have can select book section in first dropdown, populates chapters in second drop down. e.g:

var list1 = [             {'when':'0','value':'0','text':'chapter 1'},             {'when':'0','value':'1','text':'chapter 2'},             {'when':'0','value':'2','text':'chapter 3'},                             ...(snip..)              {'when':'1','value':'0','text':'appendix 1'},             {'when':'1','value':'1','text':'appendix 2'},             {'when':'1','value':'2','text':'appendix 3'},                             ....(snip..) ];  function commontemplate(item){    return "<option value='" + item.value + "'>" + item.text + "</option>"; };  function commontemplate2(item) {             return "<option value='" + item.value + "'>***" + item.text + "***</option>";          };          function commonmatch(selectedvalue) {             return this.when == selectedvalue;          }; 

which called by:

jquery(document).ready(function()     {            jquery("#section").cascade("#chapter",{                              list: list1,                         template: commontemplate,             match: commonmatch                   });     }); 

my form pre-populated section0 , it's associated chapters. works fine - when select book 2, script fires , populates second drop down chapters book 2 etc.

my problem is: when select book "section 2, chapter 3", book , chapter load while form on page displays "section 2, chapter 3". way user can go chapter 4 or whatever. currently, when section 2, chapter 3 loads, form defaults "section 1, chapter 1" default form value first time user arrived @ page.

my question is: how can have default value first time, when user submits form, page reloads remembering last selected section/chapter in form?

thanks.


Comments

Popular posts from this blog

apache - Add omitted ? to URLs -

redirect - bbPress Forum - rewrite to wwww.mysite prohibits login -

php - How can I stop spam on my custom forum/blog? -