<!-- JavaScript:Cookies code snippet 7. -->
<!-- Passing cookie values from page to page using multiple cookies. -->
<!-- Use of the 'post' method attribute of the form and transient cookies
to hide the cookie values being passed. -->

<!-- First page -->
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<!-- Code source: http://www.justfigures.co.uk/ -->
<!-- A resource for web developers using XHTML, CSS, JavaScript, PHP -->
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>View code snippet page</title>
<script language="JavaScript" type="text/javascript">
//<![CDATA[
/* this function is same as 'setCookie()' JavaScript: Cookies
code snippet 3 but without the expiry date argument */
function setCookie(name,value){
document.cookie = name + "=" + value + ";path=/"
}
/* function to add the values of the form elements to individual cookies,
this function calls setCookie() above */
function setValues(aForm){
setCookie("nameCookie",aForm.name7a.value)
setCookie("emailCookie",aForm.email7a.value)
}
//]]>
</script>
</head>

<body>
<form name="frm7a" id="frm7a" method="post" onsubmit="return setValues(this)" action="7b_testCookieA.php">
<!-- where '7b_testCookieA.php' is the file name of the second page,
change this as required -->
<h1>First page</h1><br />
Please enter your name:<br />
<input type="text" name="name7a" value="" size="60" /><br />
Please enter your email address:<br />
<input type="text" name="email7a" value="" size="60" /><br /><br />
<input type="submit" value="Proceed to page 2 of the form" />
</form> 
</body>
</html>


<!-- Second page -->
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<!-- Code source: http://www.justfigures.co.uk/ -->
<!-- A resource for web developers using XHTML, CSS, JavaScript, PHP -->
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>View code snippet page</title>
<script language="JavaScript" type="text/javascript">
//<![CDATA[
/* function to retrieve the form elements from the individual cookies,
this function calls getCookie() */
// for function getCookie() see JavaScript: Cookies code snippet 4
function getValues(){
var nameValue7b=getCookie("nameCookie")
var emailValue7b=getCookie("emailCookie")
if (nameValue7b != false){
	document.frmTestCookie7b.name7b.value = nameValue7b
	}
if (emailValue7b != false){
	document.frmTestCookie7b.email7b.value = emailValue7b
	}
}
//]]>
</head>

<!-- Note use of 'body' onload event -->
<body onload="return getValues()">
<!-- note that the form's action has been cancelled -->
<h1>Second page</h1><br />
<form name="frmTestCookie7b" action="#">
You have previously entered your name:<br />
<input type="text" name="name7b" value="" size="60" /><br />
You have previously entered your email address:<br />
<input type="text" name="email7b" value="" size="60" /><br />
The form could now present more questions to the user.<br />
</form> 
</body>
</html>