Hey
I have a text box, in which a user enters his/her name. How can I set it so that it 'saves' the users name via a cookie, and then recalls it into the same text box, next time the user visits the page?
Thanks for your help
James
Printable View
Hey
I have a text box, in which a user enters his/her name. How can I set it so that it 'saves' the users name via a cookie, and then recalls it into the same text box, next time the user visits the page?
Thanks for your help
James
<head>
<script language="javascript">
<!--
function checkC()
{
var the_cookie=unescape(document.cookie).split(":");
if(the_cookie[1])
{
document.getElementById("username").value=the_cookie[1];
document.getElementById("cName").style.visibility="hidden";
}
}
function savecookie()
{
var username=document.getElementById("username").value;
var the_date=new Date("December 31, 2023");
the_date.toGMTString();
document.cookie="myCookie="+escape(username);+";expires="+the_date;
}
-->
</script>
</head>
<body onLoad="checkC()">
<input type=text id=username>
<input type=button onClick="savecookie" id=cName value="save cookie">
</body>
i didnt test this or anything. hope it works:)