Tip

Set And Read A Cookie From A Notes Form.

This javascript when used in a notes form will both set and read a cookie on
the users browser.
For each field you are using in your cookie in the "onBlur" event, you must
enter:

setCookie()

This Goes in the "JSHeader" in R5 or the header of the form
<!-- hide from older browsers
function setCookie()
{
expireDate = new Date();
y1 = expireDate.getYear();
if (y1 < 100)
{
y1 = y1 + 1900;
}
expireDate.setYear(y1 + 1);
e1 = ";expires=" + expireDate.toGMTString() + ";path=";
document.cookie = "PostedBy=" + document.forms[0].PostedBy.value + e1;
document.cookie = "eMailAddress=" + document.forms[0].eMailAddress.value + e1;
document.cookie = "ImageURL=" + document.forms[0].ImageURL.value + e1;
}
// end hide -->

This Goes at the very bottom of the form form
<SCRIPT>
if ((document.cookie != "") && (document.forms[0].PostedBy))
{
c1 = document.cookie.split(";");
if (c1[0] != "")
{
document.forms[0].PostedBy.value = c1[0].split("=") [1]
}
if (c1[1] != "")
{
document.forms[0].eMailAddress.value = c1[1].split("=") [1]
}
if (c1[2] != "")
{
document.forms[0].ImageURL.value = c1[2].split("=") [1]
}
if (c1[3] != "")
{
document.forms[0].UserHostName.value = c1[3].split("=") [1]
}
}
</SCRIPT>

This was first published in November 2000

Disclaimer: Our Tips Exchange is a forum for you to share technical advice and expertise with your peers and to learn from other enterprise IT professionals. TechTarget provides the infrastructure to facilitate this sharing of information. However, we cannot guarantee the accuracy or validity of the material submitted. You agree that your use of the Ask The Expert services and your reliance on any questions, answers, information or other materials received through this Web site is at your own risk.