I have check boxes against folders in the tree structure.Can someone suggest me for one issue which I am facing in the check-box states. I need to retrieve the checked states for the check-boxes from the cookie session . At the moment I am able to retrieve the ids corresponding to the checked check-boxes from the cookies session. I want to retrieve the checked state of the check-box as well upon pageload() corresponding to those folder ids which I am able to fetch at the moment. I am making use of plain java-script in my entire logic.
Is there a way to do it here idArr is the array of the folder ids of the selected checkboxes, can I get the states of the check-boxes as well?Can any one suggest?
window.onload=function(){
var test = ReadCookie("Boxer");
alert("ReadCookie: "+test);
};
function CreateCookie(name,value,days)
{
if (days)
{
var date = new Date();
date.setTime(date.getTime()+(days*24*60*60*1000));
var expires = "; expires="+date.toGMTString();
}
else var expires = "";
document.cookie = name + "=" + value + expires + "; path=/";
alert("cookie created");
}
function ReadCookie(name)
{
var nameEQ = name + "=";
var ca = document.cookie.split(';');
for(var i=0;i < ca.length;i++) {
var c = ca[i];
while (c.charAt(0)==' ') c = c.substring(1,c.length);
if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
}
return null;
}
function CheckCookies()
{
var CurrentCookie = ReadCookie("Boxer");
for (i=0; i<document.CheckList.elements.length; i++)
{
if (document.CheckList.elements[i].type == "checkbox")
{
if (CurrentCookie.indexOf(document.CheckList.elements[i].id) > -1)
{
document.CheckList.elements[i].checked = 1;
}
}
}
}
/** I am calling the create cookie method while creation of the checkboxes and passing the array of the checked folder ids corresponding to the check boxes which are in checked state as below:- **/
CreateCookie("Boxer",idArr,"100");
may be u can keep the id and check state in same index of idArr,by comma separating them
while(i<NoOfNodes)
{
idArr[i++]=id+','+isChecked;
}
And Retrieve them by Splitting the value