Hi. I am trying to use a cookie to get a name entered in a form to show on the redirect page.
I am using a Mac, with email.cgi for the form
The problem I am having is that "undefined" is showing on the redirect page instead of the name.
I am using the following script:
ON FORM PAGE:
<SCRIPT LANGUAGE="JavaScript"><!--
function setCookie(NameOfCookie, value) {
document.cookie = NameOfCookie + "=" + escape(value)
}
function next() {
if (document.forms[0].name.value=="" {
alert("You didn't enter a name."
return false
}
else {
setCookie('Name',document.forms[0].name.value)
window.location="calvertdirect.html"
}
} //-->
</SCRIPT>
IN FORM:
<input type="text" name="name" maxlength="80" size="15">
<input type="text" name="from_address" maxlength="80" size="15">
<input onclick="return next()" type="submit" name="Go" value="Go">
ON REDIRECT PAGE:
<SCRIPT LANGUAGE="JavaScript">
<!--
function getCookie(NameOfCookie){
if (document.cookie.length > 0) {
begin = document.cookie.indexOf(NameofCookie+"="
if (begin != -1) {
begin += NameOfCookie.length+1;
end = document.cookie.indexOf(";", begin)
if (end == -1) end = document.cookie.length
return unescape(document.cookie.substring(begin, end))
}
}
return ""
}
var Name=getCookie('Name')
//-->
</SCRIPT>
<STYLE TYPE="TEXT/CSS">
.name {
font-family: Verdana;
font-size: 16px;
position: absolute;
}
</STYLE>
IN BODY:
<span class="name" style="left: 205px; top: 320px"></span>
<p align="left"><font face="Arial, Helvetica, sans-serif" size="3" color="#000000">
<script language="javascript">
<!--
document.write(Name)
//-->
</script>
I am sure this is a simple error, because I don't know much about JavaScript. I would very much appreciate any help you could give me with this.
Thanks,
Jeanne
I am using a Mac, with email.cgi for the form
The problem I am having is that "undefined" is showing on the redirect page instead of the name.
I am using the following script:
ON FORM PAGE:
<SCRIPT LANGUAGE="JavaScript"><!--
function setCookie(NameOfCookie, value) {
document.cookie = NameOfCookie + "=" + escape(value)
}
function next() {
if (document.forms[0].name.value=="" {
alert("You didn't enter a name."
return false
}
else {
setCookie('Name',document.forms[0].name.value)
window.location="calvertdirect.html"
}
} //-->
</SCRIPT>
IN FORM:
<input type="text" name="name" maxlength="80" size="15">
<input type="text" name="from_address" maxlength="80" size="15">
<input onclick="return next()" type="submit" name="Go" value="Go">
ON REDIRECT PAGE:
<SCRIPT LANGUAGE="JavaScript">
<!--
function getCookie(NameOfCookie){
if (document.cookie.length > 0) {
begin = document.cookie.indexOf(NameofCookie+"="
if (begin != -1) {
begin += NameOfCookie.length+1;
end = document.cookie.indexOf(";", begin)
if (end == -1) end = document.cookie.length
return unescape(document.cookie.substring(begin, end))
}
}
return ""
}
var Name=getCookie('Name')
//-->
</SCRIPT>
<STYLE TYPE="TEXT/CSS">
.name {
font-family: Verdana;
font-size: 16px;
position: absolute;
}
</STYLE>
IN BODY:
<span class="name" style="left: 205px; top: 320px"></span>
<p align="left"><font face="Arial, Helvetica, sans-serif" size="3" color="#000000">
<script language="javascript">
<!--
document.write(Name)
//-->
</script>
I am sure this is a simple error, because I don't know much about JavaScript. I would very much appreciate any help you could give me with this.
Thanks,
Jeanne