473,396 Members | 1,816 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

setting a cookie - should be easy.

this is not specifically behaviour related, but i thought i would risk
asking anyway.

i am working on a script that triggers a blind down or blind up effect
by clicking on a particular link. it then remembers the status of that
choice by setting a cookie.

the technique was taken from here:

http://www.exit404.com/2005/57/unobt...culous-effects

here is my rule

'a.tools' : function(el){
el.onclick = function(){
if (Element.hasClassName('tool-box', 'invisible')) {
new Effect.BlindDown('tool-box');
Element.removeClassName('tool-box', 'invisible');
setCookie(this.parentNode.id, '', 365);
} else {
new Effect.BlindUp('tool-box');
Element.addClassName('tool-box', 'invisible');
setCookie(this.parentNode.id, 'invisible', 365);
}
}
}

the problem is this line

setCookie(this.parentNode.id, '', 365);

that was taken directly from the artilcle but does not apply to my
situation. in the article he is applying the effects to the same
element that is clicked on, so 'this' is used in the function, where as
i am using 'tool-box', which is the id of the div that is getting
triggered.

so when i get the setCookie part, i need to rewrite it so that it
associates itself with the div 'tool-box instead of 'this'. basically i
just do not know the proper syntax. i tried...

setCookie('tool-box', 'invisible', 365);

but that did not seem to work for me.

any thoughts?

p.s. i did not include the cookie stuff because i do not think it is
needed, but if you think it would be helpful, i can included or you can
find it in the article.

Jan 22 '07 #1
2 1284
anathema wrote:
>
this is not specifically behaviour related, but i thought i would risk
asking anyway.

i am working on a script that triggers a blind down or blind up effect
by clicking on a particular link. it then remembers the status of that
choice by setting a cookie.

the technique was taken from here:

http://www.exit404.com/2005/57/unobt...culous-effects

here is my rule

'a.tools' : function(el){
el.onclick = function(){
if (Element.hasClassName('tool-box', 'invisible')) {
new Effect.BlindDown('tool-box');
Element.removeClassName('tool-box', 'invisible');
setCookie(this.parentNode.id, '', 365);
} else {
new Effect.BlindUp('tool-box');
Element.addClassName('tool-box', 'invisible');
setCookie(this.parentNode.id, 'invisible', 365);
}
}
}

the problem is this line

setCookie(this.parentNode.id, '', 365);

that was taken directly from the artilcle but does not apply to my
situation. in the article he is applying the effects to the same
element that is clicked on, so 'this' is used in the function, where as
i am using 'tool-box', which is the id of the div that is getting
triggered.

so when i get the setCookie part, i need to rewrite it so that it
associates itself with the div 'tool-box instead of 'this'. basically i
just do not know the proper syntax. i tried...

setCookie('tool-box', 'invisible', 365);

but that did not seem to work for me.

any thoughts?

p.s. i did not include the cookie stuff because i do not think it is
needed, but if you think it would be helpful, i can included or you can
find it in the article.
(I don't have the time to examine it closely, but I think this is
right...someone please correct me if I'm mistaken):

The reason the script uses "this" is because it is attaching a behaviour
to a class; that is, all elements belonging to that class will inherit
the behaviour, which will affect the element itself when clicked.
Unless you want all of the links in a class to have exactly the same
effect (which could be to roll up some other element named "toolbox"),
you need to put a different onclick event in each link, which calls a
function with the appropriate name given as a parameter.
Jan 23 '07 #2
I know why it is using 'this' for the original script. It is setting
the cookie for a.tools. I want to set it for tool-box, i just do not
know the syntax.

On Jan 22, 5:27 pm, Gary Hasler <garyhas...@thelogconnection.com>
wrote:
anathema wrote:
this is not specifically behaviour related, but i thought i would risk
asking anyway.
i am working on a script that triggers a blind down or blind up effect
by clicking on a particular link. it then remembers the status of that
choice by setting a cookie.
the technique was taken from here:
http://www.exit404.com/2005/57/unobt...criptaculous-e...
here is my rule
'a.tools' : function(el){
el.onclick = function(){
if (Element.hasClassName('tool-box', 'invisible')) {
new Effect.BlindDown('tool-box');
Element.removeClassName('tool-box', 'invisible');
setCookie(this.parentNode.id, '', 365);
} else {
new Effect.BlindUp('tool-box');
Element.addClassName('tool-box', 'invisible');
setCookie(this.parentNode.id, 'invisible', 365);
}
}
}
the problem is this line
setCookie(this.parentNode.id, '', 365);
that was taken directly from the artilcle but does not apply to my
situation. in the article he is applying the effects to the same
element that is clicked on, so 'this' is used in the function, where as
i am using 'tool-box', which is the id of the div that is getting
triggered.
so when i get the setCookie part, i need to rewrite it so that it
associates itself with the div 'tool-box instead of 'this'. basically i
just do not know the proper syntax. i tried...
setCookie('tool-box', 'invisible', 365);
but that did not seem to work for me.
any thoughts?
p.s. i did not include the cookie stuff because i do not think it is
needed, but if you think it would be helpful, i can included or you can
find it in the article.(I don't have the time to examine it closely, but I think this is
right...someone please correct me if I'm mistaken):

The reason the script uses "this" is because it is attaching a behaviour
to a class; that is, all elements belonging to that class will inherit
the behaviour, which will affect the element itself when clicked.
Unless you want all of the links in a class to have exactly the same
effect (which could be to roll up some other element named "toolbox"),
you need to put a different onclick event in each link, which calls a
function with the appropriate name given as a parameter.
Jan 23 '07 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: bagsmode | last post by:
Hi, I'm trying to set a session cookie and then redirect, however I get the error: Status: 302 Moved Location: /index.cgi I thought I recall getting an error like this when I first tried...
1
by: Jose Olivas | last post by:
I am setting a cookie on a subdomain: http://store1.mydomain.com Then the store takes me to a shopping cart that is at: http://shopping.mydomain.com Somewhere the following code (taken and...
0
by: Chris | last post by:
Hi all, I'm having trouble setting an authorization cookie from a web service. I need to set an authorization cookie on the client machine when the proper soap header is sent with...
2
by: junlia | last post by:
Hi All, I am working on a project that acts as a bridge. It does some checking with post xml data, and then redirects the request to an appropriate page. However, we find that depends on the...
1
by: laredotornado | last post by:
Hi, I'm using PHP 4.4.4 on Apache 2 on Fedora Core 5. PHP was installed using Apache's apxs and the php library was installed to /usr/local/php. However, when I set my "error_reporting"...
4
by: SevDer | last post by:
Hi, I've done some coding in my web application however right now for an unknown reason my asp.net 2.0 site is not setting asp.net_sessionid cookie and as a result, I am losing the session data...
2
by: sophie_newbie | last post by:
Hi, I'm wondering how do you set a 'timeout' or expiry date/time for a cookie set using a python cgi script. I can set a cookie ok but I dunno how to set the expiry time so it always expires at...
3
by: rjoseph | last post by:
Hi Guys I hope this is an easy one for you. Basically I have a page on my website that creates a javascript based cookie on the users pc. The contents of the cookie when created looks as...
5
by: sophie_newbie | last post by:
Does anyone know how to do this? I can't seem to make it work. I'm using: c = Cookie.SimpleCookie() c = "unamepwordwhatever" c.expires = time.time() + 300 print c
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.