Home › Forums › Back End › Remember Dropdown Selection › Re: Remember Dropdown Selection
I’ve found some script (below) which is working for one of the Select Lists (MinPrice). I also need to target the second Select List (MaxPrice), how would I do that?
var saveString = "";
function getCookie(isName){
var cookieStr = document.cookie;
var startSlice = cookieStr.indexOf(isName+"=");
if (startSlice == -1){return false}
var endSlice = cookieStr.indexOf(";",startSlice+1)
if (endSlice == -1){endSlice = cookieStr.length}
var isData = cookieStr.substring(startSlice,endSlice)
var isValue = isData.substring(isData.indexOf("=")+1,isData.length);
return isValue;
}
function saveForm(){
var saveString = "";
var nText = document.getElementsByTagName('input');
for (i=0; i
var isIdx = document.forms[0].selectedIndex;
saveString = saveString+isIdx;
document.cookie = "formData="+saveString+"";
}
function restoreValues(){
var nValues = getCookie('formData');
var n = 0;
if (nValues)
{
//alert(nValues)
var isIndex = nValues.substring(nValues.length-1,nValues.length);
document.forms[0].selectedIndex = isIndex;
var nForm = document.forms[0];
nValues = nValues.substring(0,nValues.length-1);
var isText = nValues.split(":");
for (i=0; i
if (nForm.type == "text")
{nForm.value = isText[n++]}
}
}
}
onload=restoreValues;
onbeforeunload=saveForm;