setting cookie works, but 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;
}
 
G

Gunnar Hjalmarsson

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!

You should have spent a minute figuring out an appropriate Usenet group.
This group is about Perl.

<JavaScript(?) code snipped>
 
T

Tintin

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;
}

You need to fix all your Perl errors first.

$ perl -cw foo
Unquoted string "t" may clash with future reserved word at foo line 1.
Unquoted string "document" may clash with future reserved word at foo line
3.
Unquoted string "t" may clash with future reserved word at foo line 3.
Unquoted string "document" may clash with future reserved word at foo line
4.
Unquoted string "t" may clash with future reserved word at foo line 4.
Unquoted string "document" may clash with future reserved word at foo line
5.
Unquoted string "t" may clash with future reserved word at foo line 5.
Unquoted string "para" may clash with future reserved word at foo line 9.
Unquoted string "style" may clash with future reserved word at foo line 9.
Unquoted string "display" may clash with future reserved word at foo line 9.
Unquoted string "para" may clash with future reserved word at foo line 11.
Unquoted string "style" may clash with future reserved word at foo line 11.
Unquoted string "display" may clash with future reserved word at foo line
11.
Unquoted string "tb" may clash with future reserved word at foo line 12.
Unquoted string "style" may clash with future reserved word at foo line 12.
Unquoted string "display" may clash with future reserved word at foo line
12.
Unquoted string "htb" may clash with future reserved word at foo line 13.
Unquoted string "style" may clash with future reserved word at foo line 13.
Unquoted string "display" may clash with future reserved word at foo line
13.
Unquoted string "v" may clash with future reserved word at foo line 15.
Unquoted string "null" may clash with future reserved word at foo line 15.
Unquoted string "v" may clash with future reserved word at foo line 16.
Unquoted string "t" may clash with future reserved word at foo line 16.
Unquoted string "v" may clash with future reserved word at foo line 19.
Unquoted string "t" may clash with future reserved word at foo line 19.
Unquoted string "v" may clash with future reserved word at foo line 22.
Unquoted string "para" may clash with future reserved word at foo line 27.
Unquoted string "style" may clash with future reserved word at foo line 27.
Unquoted string "display" may clash with future reserved word at foo line
27.
Unquoted string "tb" may clash with future reserved word at foo line 28.
Unquoted string "style" may clash with future reserved word at foo line 28.
Unquoted string "display" may clash with future reserved word at foo line
28.
Unquoted string "htb" may clash with future reserved word at foo line 29.
Unquoted string "style" may clash with future reserved word at foo line 29.
Unquoted string "display" may clash with future reserved word at foo line
29.
Unquoted string "v" may clash with future reserved word at foo line 31.
Unquoted string "null" may clash with future reserved word at foo line 31.
Unquoted string "v" may clash with future reserved word at foo line 32.
Unquoted string "v" may clash with future reserved word at foo line 32.
Unquoted string "t" may clash with future reserved word at foo line 32.
Unquoted string "v" may clash with future reserved word at foo line 35.
Unquoted string "v" may clash with future reserved word at foo line 39.
Unquoted string "true" may clash with future reserved word at foo line 41.
syntax error at foo line 1, near ") {"
syntax error at foo line 42, near "}"
foo had compilation errors.
 

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

Forum statistics

Threads
473,743
Messages
2,569,478
Members
44,898
Latest member
BlairH7607

Latest Threads

Top