The Web Design Group

... Making the Web accessible to all.

Welcome Guest ( Log In | Register )

 
Reply to this topicStart new topic
> Javescript trouble
jordan t
post Oct 6 2010, 04:30 AM
Post #1





Group: Members
Posts: 1
Joined: 6-October 10
Member No.: 12,875



hey i am having a bit of trouble setting a script for a cookie (javerscript) and my problem is that it only says "Welcome 'Forename' but doesnt say anything else and no ther prompts come up


function setCookie(c_name,value,expiredays)
{
var exdate=new Date();
exdate.setDate(exdate.getDate()+expiredays);
document.cookie=c_name+ "=" +escape(value)+
((expiredays==null) ? "" : ";expires="+exdate.toUTCString());
}

function checkCookie()
{
forename=getCookie('forename');
surname=getCookie('surname');
if (forename!=null && forename!="" && surname!=null && surname!="" && age!=null && age!="" && age<="5" && age >="100")
{
alert('Welcome again '+forename+' ' +surname+ '. You are ' +age+ ' years old !');
}
else
{
forename=prompt('Please enter your Forename:',"");
if (forename!=null && forename!="")
{
setCookie('forename',forename,360);
surname=prompt('Please enter your Surname:',"");
if (surname!=null && surname!="")
{
setCookie('surname',surname,400);
age=prompt('Please enter your Age:',"");
if (age!="null" && age!="" && age!="NAN")
{
setCookie('age',age,460);
}
}
}
}
}

formated correctly in notepad++

This post has been edited by jordan t: Oct 6 2010, 04:33 AM
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
Christian J
post Oct 6 2010, 06:57 AM
Post #2


.
********

Group: WDG Moderators
Posts: 8,043
Joined: 10-August 06
Member No.: 7



I just get a JS error, apparently due to the unknown "getCookie" method.
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post

Reply to this topicStart new topic
1 User(s) are reading this topic (1 Guests and 0 Anonymous Users)
0 Members:

 



- Lo-Fi Version Time is now: 21st February 2019 - 03:16 AM