Hi,
why in cookies put only one value(id)?
When i refresh page all my settings remain, but now there is only one...
Thanks
<script type="text/javascript">
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=/";
}
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 change(id){
ID = document.getElementById(id);
if(ID.style.display == "")
ID.style.display = "none";
else
ID.style.display = "";
createCookie("id",id,7); /* 1 week */
}
window.onload = function() {
try{change(readCookie("id"));}catch(e){} //rough example
};
</script>
<div>
<div onclick="change(5)" style="cursor: hand">
<a href = "#">+</a>News
</div>
<div style="display: none" id="5">
News1<br/>
News2<br/>
</div>
<div onclick="change(4)" style="cursor: hand">
<a href = "#">+</a>News2
</div>
<div style="display: none" id="4">
News2 1<br/>
News2 2<br/>
</div>
</div>