PDA

View Full Version : cookie get value function not working.



antonyf
11-05-2011, 12:49 PM
Hi, im trying to pull the email value from a cookie, then split the email into 2 parts to use as value for input box.. but its not working out.
here is my code:


<script type="text/javascript">
function getCookie(mailaddress)
{
var i,x,y,ARRcookies=document.cookie.split(";");
for (i=0;i<ARRcookies.length;i++)
{
x=ARRcookies.substr(0,ARRcookies.indexOf("="));
y=ARRcookies.substr(ARRcookies.indexOf("=")+1);
x=x.replace(/^\s+|\s+$/g,"");
if (x==mailaddress)
{
var thisemail=y;
}
var email_split=thisemail.split("@");
var email_name=email_split[0];
var email_domain=email_split[1];
}
}
</script>

<input size="20" class="text" name="_username" type="text" value="<myCookie: var email_name />" readonly>

jscheuer1
11-05-2011, 03:29 PM
The way that's set up makes no sense to me. The function function getCookie(function getCookie(mailaddress)) takes as a parameter function getCookie(mailaddress).

If you already know the mailaddress, why are you checking to see if it's in a cookie?