// ************************************************************ // Name : addproducttohistory() // Purpose : Add product into history cookie // Change Requests: // Name Date Summary // ************************************************************ function addproducttohistory(productId){ var strHistoryBasket = ""; strHistoryBasket = getCookie("historyBasket"); if(strHistoryBasket==null||strHistoryBasket.length < 1){ strHistoryBasket = "{\"id\":\"" + productId + "\"}"; }else{ //We now see if this product already exists in the history var bolFound = false; var j = eval("[" + strHistoryBasket + "]"); strHistoryBasket = ""; for (var i = 0 ; i < j.length ; i++) { if(j[i]["id"]==productId){bolFound = true;} strHistoryBasket = strHistoryBasket + "{\"id\":\"" + j[i]["id"] + "\"},"; } if(bolFound==false){strHistoryBasket = "{\"id\":\"" + productId + "\"}," + strHistoryBasket;} strHistoryBasket = Left(strHistoryBasket, strHistoryBasket.length-1); //We now double check that the length of the history basket is no longer than the max allowed var j = eval("[" + strHistoryBasket + "]"); if(j.length > 20){ strHistoryBasket = ""; for (var i = 0 ; i < j.length-1 ; i++) { strHistoryBasket = strHistoryBasket + "{\"id\":\"" + j[i]["id"] + "\"},"; } strHistoryBasket = Left(strHistoryBasket, strHistoryBasket.length-1); } } setCookie("historyBasket", strHistoryBasket, "", "/", "", ""); if(strHistoryBasket.length > 0){document.getElementById("formBasket_strHistoryBasket").value = "[" + strHistoryBasket + "]";}else{document.getElementById("formBasket_strHistoryBasket").value = "";} } // ************************************************************ // Name : clearhistory() // Purpose : Clear our the history cookies // Change Requests: // Name Date Summary // ************************************************************ function clearhistory(){ setCookie("historyBasket", "", "", "/", "", ""); document.getElementById("formBasket_strHistoryBasket").value = ""; location.reload(true); }