Setting cookie works, editing doesn't

C

ca

I'm using about 30 blocks with links on my page, that can be opened or
closed by users so they're able to select which links should be
displayed on their 'personal' page.

Just closing blocks for the first time works fine, but returning
visitors that want to open or close a new block, lose their first
setting, everything in the cookie is replaced.

I use this code, anyone got an idea? I spent days figuring it out! It
drives me crazy!

function toggle(t) {

var para=document.getElementById(t);
var tb = document.getElementById('t' + t);
var htb = document.getElementById('h' + t);

var v = GetCookieOpenClose('l');

if(para.style.display!='none') {

para.style.display = 'none';
tb.style.display = 'block';
htb.style.display = 'none';

if (v!=null) {
v += "|" + t;
} else {

v = "|" + t;
}

SetCookieOpenClose('l',v);

}
else {

para.style.display = 'block';
tb.style.display = 'none';
htb.style.display = 'block';

if (v!=null) {
v = v.Replace("|" + t,"");
}

SetCookieOpenClose('l',v);

}

v = GetCookieOpenClose('l');

return true;
}
 
T

Thomas 'PointedEars' Lahn

(e-mail address removed) wrote:

[pretty printed:]
function toggle(t)
{
var para= document.getElementById(t);
var tb = document.getElementById('t' + t);
var htb = document.getElementById('h' + t);

You have feature-tested the method before you call it, yes?
var v = GetCookieOpenClose('l');

if (para.style.display!='none')
{
para.style.display = 'none';
tb.style.display = 'block';
htb.style.display = 'none';

if (v!=null)
{
v += "|" + t;
}
else
{
v = "|" + t;
}

SetCookieOpenClose('l',v);
}
else
{
para.style.display = 'block';
tb.style.display = 'none';
htb.style.display = 'block';

if (v!=null)
{
v = v.Replace("|" + t,"");
}

SetCookieOpenClose('l',v);

}

v = GetCookieOpenClose('l');

return true;
}

Now that you have posted which methods you call to set and retrieve cookie
data, it is time that you post their code (because they are not built-ins),
and say what exactly does not work in what way.


PointedEars
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,756
Messages
2,569,535
Members
45,008
Latest member
obedient dusk

Latest Threads

Top