FAQ
Members List
Calendar
Mark Forums Read
if cookie = ""
HighDots Forums
Javascript Newsgroups
JavaScript discussion (multi-lingual)
if cookie = ""
JavaScript discussion (multi-lingual)
JavaScript discussion (alt.comp.lang.javascript)
Discuss
if cookie = ""
in the
JavaScript discussion (multi-lingual)
forum.
Thread Tools
Display Modes
#
1
screechyboy@googlemail.com
Posts: n/a
if cookie = "" -
09-26-2007 , 03:25 PM
OKay so im new to Javascript Cookies....
I am able to set and return cookie values but i know want to create
an
if statement!
One of my cookies is called "color" and i wish to write a script that
displays a certain graphic if "Color" equals "White" for example.
The code i have so far is...
<script type="text/javascript">
color=getCookie('color')
if (color="White")
{
alert('Color = '+color+'!')
}
</script>
The alert appears when the page loads but ignores the IF statement so
just displays the value of "color" regardless of wether its value is
"White".
Im stuck and google searching is getting me knowhere, can this be
done?
Your help is greaty appreciated!
screechyboy@googlemail.com
#
2
Kirk Zurell
Posts: n/a
Re: if cookie = "" -
09-27-2007 , 04:06 PM
screechyboy (AT) googlemail (DOT) com wrote:
Quote:
if (color="White")
This is an assignment, not a test. Use '==' to test 'color'.
It is a valid expression, though. Some people write code like this:
if ( "White" == color ) ...
If you forget the second equals sign, the assignment fails. Not my
preference.
Kirk
--
Kirk Zurell
Byte Craft Limited
Waterloo, Ontario, Canada
http://www.bytecraft.com
Kirk Zurell
«
Previous Thread
|
Next Thread
»
Thread Tools
Show Printable Version
Email this Page
Display Modes
Linear Mode
Switch to Hybrid Mode
Switch to Threaded Mode
Posting Rules
You
may not
post new threads
You
may not
post replies
You
may not
post attachments
You
may not
edit your posts
vB code
is
On
Smilies
are
On
[IMG]
code is
On
HTML code is
Off
Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
C++ Forums
-
MySQL Forums
-
Databases Forums
-
Hardware Forums
-
Borland Forums
-
Java Forums
-
Dotnet Forums
-
HighDots Forums
-
Archive
-
Top