Entering and Getting Form Data Into a Thank You Letter

2 Replies - 2972 Views - Last Post: 29 October 2006 - 09:32 PM

JavaScript Form

Posted 28 October 2006 - 12:10 AM

I need to create a form, pull the data from the form, and generate a 'Thank You' letter which incorporates various form elements. I have the three page form create but I can't get the 'Next' or 'Submit Registration' buttons to work on the second page or get the form elements to display in the 'Thank You' letter. I am really frustrated and could use some help. Here is my code:

Re: JavaScript Form

Re: JavaScript Form

Posted 29 October 2006 - 09:32 PM

hotsnoj, on 29 Oct, 2006 - 01:19 PM, said:

What are the errors?

Ok... I was able to figure this part out. The challenge I'm having now is pulling the data into a "Thank You" letter. What I would like it to say is Thank you for registering (student's name) with our school. We are very interested in meeting you and discussing (student's name)'s interest in (favorite subject)... Here is the updated code:

This is the code I would like to use to create the "Thank You" letter. I'm just not sure how to manipulate the language:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html>
<head>
<title>Registration Complete</title>
</head>
<body bgcolor="#cccccc">
<h2><img src="contract.png">Registration Complete</h2>
<p><strong>Thank you for registering with our school.</strong></p>
<script type="text/javascript">
<!-- HIDE FROM INCOMPATIBLE BROWSERS
var formData = decodeURI(location.search);
formData = formData.substring(1, formData.length);
var formArray = formData.split("&");
for (var i=0; i < formArray.length; ++i) {
document.write(formArray[i] + "<br />");
}
// I added the code below showing you how you can parse exactly what you want from each location of the array.
for (var i=0; i < formArray.length; ++i) {
document.write("Thank you for signing Mr." + formArray[i].indexOf('=') + "<BR>"); // writes out the position of the equal =
var eqIndex= formArray[i].indexOf('='); // store the position in a variable
document.write("<B>position of ';' sign </B>" + formArray[i].indexOf(';') + "<BR>"); // writes out the position of the equal;
var semclnIndex= formArray[i].indexOf(';'); // similarly store the position of the; in a variable
//eqIndex == -1 OR semclnIndex == -1 notice that if either one is -1 then you may not have entered a value, so you can create the form letter using only required fields
if (formArray[i]==0)
document.write("<B> No value entered! </B><BR><BR>"); // no value entered
if (formArray[i]==0 )
document.write(formArray[i].substring(eqIndex+1,formArray[i].length) + "<BR><BR>"); // these don't have an ending ";", so use the whole length
if (eqIndex != -1 && semclnIndex != -1)
document.write(formArray[i].substring(eqIndex+1,semclnIndex) + "<BR><BR>"); // use a substring to print out from one potioon over the = sign position to the position of the semi colon.
}
// STOP HIDING FROM INCOMPATIBLE BROWSERS -->
</script>
</body>
</html>