How To Getting Values From Cookies To Set Widgets

How To Getting Values From Cookies To Set Widgets


  • 11 Jan, 2012

    function getCookieData(labelName) {//from Danny Goodmanvar labelLen = labelName.length;// read cookie property only once for speedvar cookieData = document.cookie;var cLen = cookieData.length;var i = 0;var cEnd;while (i < cLen) {var j = i + labelLen;if (cookieData.substring(i,j) == labelName) {cEnd = cookieData.indexOf(";",j);if (cEnd == -1) {cEnd = cookieData.length;}return unescape(cookieData.substring(j+1, cEnd));}i++;}return "";}//init() is called from the body tag onload function.function init() {setValueFromCookie("brand");setValueFromCookie("market");setValueFromCookie("measure");}function setValueFromCookie(widget) {if( getCookieData(widget) != "") {document.getElementById(widget).value = getCookieData(widget);}}//if you name your cookies the widget ID, you can use the following helper functionfunction setCookie(widget) {document.cookie = widget + "=" +escape(document.getElementById(widget).value) + getExpirationString();}

    Comments Received:
    Please give your suggestions and feedback:

2009-2016 downloadmela.com. All rights reserved.