Hi,
I want to set a cookie when a form is submitted before it goes off to the formprocessor.cgi which is not ours to modify.
I have been kindly given some code to set the cookie but I am looking for how I attach it to a form submission.
In the head I have placed :
<script language="JavaScript">
<!--
var pv_Days=365; // The Links will be remembered on revisits for a specified number of days
var pv_Cookie='landasp'; // The Cookie name
function pv_SetCookie() {
document.cookie=pv_Cookie+"="+escape(value)+";expires="+new Date(new Date().getTime()+pv_Days*86400000).toGMTString()+";path=/;"
}
//-->
</script>
and then in tha body I wrote:
<script language="javascript">
if (!pv_GetCookie()){
document.write ('<div class=\\"register\\"> <strong>REGISTER NOW!*</strong><br>');
document.write ('<span class=\\"side\\">For availability & offers </span></div>');
document.write ('<div class=\\"register\\">');
document.write ('<form action=\\"http://www.grow-fresh.com/cgi-bin/formProcess.pl\\" name=\\"reserve\\" id=\\"reserve\\" onsubmit=\\"pv_SetCookie\\">');
document.write ('<input name=\\"recipient\\" type=\\"hidden\\" value=\\"stewart@landaspirations.com\\">');
document.write ('<input name=\\"subject\\" type=\\"hidden\\" value=\\"Register Now\\">');
document.write ('<input type=\\"hidden\\" name=\\"redirect\\" value=\\"http://www.landaspirations.com/buying.htm\\">');
document.write ('<input type=\\"hidden\\" name=\\"formtype\\" value=\\"Register Now\\">');
document.write ('<span class=\\"side\\"> Name<br>');
document.write ('<input name=\\"name\\" type=\\"text\\" id=\\"name\\" size=\\16\\" class=\\"inputf\\">');
document.write ('<br>');
document.write ('Tel<br>');
document.write ('<input name=\\"tel\\" type=\\"text\\" id=\\"tel\\" size=\\"16\\" class=\\"inputf\\">');
document.write ('<br>');
document.write ('Email<br>');
document.write ('<input name=\\"email\\" type=\\"text\\" id=\\"email\\" size=\\"16\\" class=\\"inputf\\">');
document.write ('Address<br>');
document.write ('<textarea name=\\"address\\" cols=\\"14\\" rows=\\"2\\" class=\\"inputf\\" id=\\"address\\"></textarea>');
document.write ('<br><br>');
document.write ('<input type=\\"submit\\" name=\\"Submit\\" value=\\"Submit\\" class=\\"button1\\">');
document.write ('</span>');
document.write ('</form>');
document.write ('<span class=\\"side\\">*Details are only used for items relating to LAL.</span> </div>');
} else {
document.write ('<div class="register">');
document.write ('<strong>REGISTER NOW!*</strong><br>');
document.write ('<span class="side">For availability & offers</span></div>');
document.write ('<div class="register">');
document.write ('<p><strong>THANK YOU FOR REGISTERING WITH LAND ASPIRATIONS.</strong></p>');
document.write ('<p> <span class="side">*Details are only used for items relating to LAL.</span> </p>');
document.write ('</div>');
}
</script>
What I expected was that I would see the form. Then once I submitted it I wouldn’t see it again as the cookie would be set. In Firefox javascript console I get : “pv_getCookie is not defined” how do i define it?