Goalie3533
Programmer
Hi guys.
I'm now having a problem trying to display an empty string in javascript. I successfully retrieve 2 key values from a cookie(first & last name) and display them on the page. That part works fine. The error occurs when it is a new user who doesn't have a cookie yet. I have code set up to check if firstname & lastname are equal to nothing to print something different but for some reason, even though they should be empty strings, the value "Ca" is populating both of them. Here's the portion of my code giving me problems. It's code for a user login. fname & lname are the ones I'm using to store my cookie values:
------------------------------------
strWelcome="<b>Welcome " + fName + " " + lName + "</b> | ";
if(fname = "")
{
document.write("<a href='../custlogin.asp' alt='Log into your account'>Login</a>");
}
else
{
document.write(strWelcome + "<a href='../logout.asp' alt='Logout of your account'>Logout</a>");
}
------------------------------------------
So what should be happening is if the user has no cookie, it should simply provide a link containing the word "Login", but unfortunately, it ends up reading "Welcome Ca Ca | Logout". I have no idea where this "Ca Ca" is coming from.
Any idea how I can fix this?
Thanks in advance.
-Goalie35
I'm now having a problem trying to display an empty string in javascript. I successfully retrieve 2 key values from a cookie(first & last name) and display them on the page. That part works fine. The error occurs when it is a new user who doesn't have a cookie yet. I have code set up to check if firstname & lastname are equal to nothing to print something different but for some reason, even though they should be empty strings, the value "Ca" is populating both of them. Here's the portion of my code giving me problems. It's code for a user login. fname & lname are the ones I'm using to store my cookie values:
------------------------------------
strWelcome="<b>Welcome " + fName + " " + lName + "</b> | ";
if(fname = "")
{
document.write("<a href='../custlogin.asp' alt='Log into your account'>Login</a>");
}
else
{
document.write(strWelcome + "<a href='../logout.asp' alt='Logout of your account'>Logout</a>");
}
------------------------------------------
So what should be happening is if the user has no cookie, it should simply provide a link containing the word "Login", but unfortunately, it ends up reading "Welcome Ca Ca | Logout". I have no idea where this "Ca Ca" is coming from.
Any idea how I can fix this?
Thanks in advance.
-Goalie35