Entry
How can somebody enter something into a textarea, and visit that page again and it's still there?
Apr 10th, 2003 15:21
Jean-Bernard Valentaten, Malsar Sarmal,
You would need to set a cookie, save the content of the textarea in the
cookie and read it upon revisit:
<html>
<head>
<title>MyCookie Example</title>
<script language="JavaScript">
function setTA()
{
if (navigator.cookieEnabled)
{
if (document.cookie)
document.forms[0].myTextArea.value = document.cookie;
}
}
function setCookie()
{
if (navigator.cookieEnabled)
{
document.cookie = document.forms[0].myTextArea.value;
}
}
</script>
</head>
<body onLoad="setTA();" onUnLoad="setCookie();">
<form ...>
<textarea name="myTextArea" ...></textarea>
</form>
</body>
</html>
Try it out, it should work. Please keep in mind that not everyone
accepts cookies, especially if they don't expire (I won't describe how
to create cookies that expire here, since you can find information
about that by using www.google.com *g*), so this is not a reliable
method. Also the cookie is not document bound, but domain bound.
HTH,
Jean