Jquery (select box) remeber previously selected item after back button is issued

446 Views Asked by At

I'm having a jquery easyui combobox with 3 options contained in a .html file called for example test.html. This is rewriting some url in order to pass dynamically its value, when user selects the node it wants to check:

<select id="mycombobox" class="easyui-combobox" style="width:90px;" data-options="
 onSelect: function(rec){
  $('a#link1').attr('href', '/scripts/system?' + $('#mycombobox').combobox('getValue'));
  $('a#link2').attr('href', '/scripts/memory?' + $('#mycombobox').combobox('getValue'));
  $('a#link3').attr('href', '/scripts/cpu?' + $('#mycombobox').combobox('getValue'));}">

   <option value="node1">- machine1 -</option>
   <option value="node2">- machine2 -</option>
   <option value="node3">- machine3 -</option>
</select>

 <a id="link1" href="/scripts/system?node1">SYSTEM</a>
 <a id="link2" href="/scripts/olm/memory?node1">CPU</a>
 <a id="link3" href="/scripts/olm/cpu?node1">MEMORY</a>

Everything is working just fine, but when the script is ran, and I return to the page where the select is (from where the script was fired, my case test.html) the select value returns to initial one "- machine1 -".

What I want to achieve is: When user selects for instance "- machine 2 -" and presses for example SYSTEM link, the script is fired, everything runs ok (it is a CGI_BIN which checks some unix stuff and prints in html format where i also insert a back button).

After this when user press 'back button' (back button is a link to test.html) I want that when test.html page is loaded to have the combobox set with the previously chosen value, in my case: "- machine2-".

Any help is much appreciated. Thank you.

0

There are 0 best solutions below