Dear JS Experts,

Can anyone provide a solution to this ?

We use DHTMLX and there is a dropdown filter. We use cookies to save the result. When someone filters by First Name, you get the first name list and when you reload, the list remains as First Name list. However, the dropdown shows as blank.

We would like to store the value of the filter in the drop down instead of showing as a blank field(resetting) eg: Filter by First Name > First Name list shown > Reload page > First Name list shown and Dropdown to show First Name.

Ideally a pure javascript solution is needed. Any help is much appreciated.

Code:
HTML Automatically generated by DHTML grid

    <td class=" filter" style="cursor: default;"><select style="width: 90%;"><option value=""></option><option value="Recomend">Recomend</option>
<option value="Benchmark">Benchmark </option>
<option value="Reject"> Reject</option>
<option value="Age">Age</option>
<option value="Transfer">Transfer </option>
</select></td>
    <td class=" filter" style="cursor: default;">
<select style="width: 90%;"><option value=""></option>
<option value="First Name">First Name</option>
<option value="Last Name">Last Name</option>
<option value="Status"> Status</option>
<option value="Education">Education</option>
<option value="Earning">Earning</option></select></td>

OUR CODE

 mygrid.init();   
    var f_ind=[];
    var f_data=[];
    mygrid.attachEvent("onFilterStart",function(ind,data){
    alert("Jim "+ mygrid.getFilterElement(6).value);//testing
    setCookie("location_filter",mygrid.getFilterElement(6).value,365);
    setCookie("awaiting_filter",mygrid.getFilterElement(7).value,365);
   return true;
});

/*************/

function getCookie(c_name){
var i,x,y,ARRcookies=document.cookie.split(";");
for (i=0;i<ARRcookies.length;i++){
  x=ARRcookies[i].substr(0,ARRcookies[i].indexOf("="));
  y=ARRcookies[i].substr(ARRcookies[i].indexOf("=")+1);
  x=x.replace(/^\s+|\s+$/g,"");
  if (x==c_name){
    return unescape(y);
    }
  }
}

function setCookie(c_name,value,exdays, secure){
var exdate=new Date();
exdate.setDate(exdate.getDate() + exdays);
var c_value=escape(value) + ((exdays==null) ? "" : "; expires="+exdate.toUTCString());
document.cookie=c_name + "=" + c_value + secure; 'path=/';
}

/*****************/

    mygrid.enableHeaderMenu();
    mygrid.enableRowsHover(true,"colourise");
    mygrid.enableColumnMove(true);

    //populate the grid with data by loading the xml file
    xmlstr='<rows><<@U_AW_DASH_RQH_ACT&S'../'=""&S'''=" ">></rows>';
    mygrid.parse(xmlstr, function checkCookie(){
   var first=getCookie("inbox");

   if (first!=null && first!="")
  {
   alert("Welcome again ");//testing
    mygrid.loadOrderFromCookie();
    mygrid.loadSizeFromCookie();
    mygrid.loadSortingFromCookie();
    mygrid.loadHiddenColumnsFromCookie();
    mygrid.enableAutoSizeSaving();
    mygrid.enableAutoHiddenColumnsSaving();
    mygrid.enableAutoSaving();
    mygrid.enableOrderSaving();
    mygrid.enableSortingSaving();

   var filter_cookie=getCookie("location_filter");
   var filter_cookie2=getCookie("awaiting_filter");

   alert("Sunit " + filter_cookie); //testing
   if (filter_cookie!=null && filter_cookie!=""){
   alert("Brian "+ filter_cookie);//testing
   mygrid.filterBy(6, filter_cookie, true);
}
if (filter_cookie2!=null && filter_cookie2!="") {
   alert("Andy "+ filter_cookie2);//testing
   mygrid.filterBy(7, filter_cookie2, true);}
 }
else
{
  alert("First Visit");//testing
  setCookie("inbox","visited",365);

  mygrid.sortRows(3,"date","des");
  mygrid.setColumnHidden(0,true);
  mygrid.setColumnHidden(1,true);
  mygrid.setColumnHidden(2,true);

    mygrid.enableAutoSizeSaving();
    mygrid.enableAutoHiddenColumnsSaving();
    mygrid.enableAutoSaving();
    mygrid.enableOrderSaving();
    mygrid.enableSortingSaving();

  }
});

checkCookie();