Outputting form into text area help !
Please check my code on a form which is meant to output results to a text area?
any help would be most appreciated!!
<html>
<head>
<title>form</title>
<script type="text/javascript" language="JavaScript">
<!--
function validatename(){
if (!document.survey.visitor.value){
alert("Please enter your name before submitting this form.");
document.survey.visitor.focus();
return false;
}else{
return true;
}
}
function validateemail(){
var theEmail = document.survey.email.value;
var atLoc = theEmail.indexOf("@",1);
var dotLoc = theEmail.indexOf(".",atLoc+2);
var len = theEmail.length;
if (atLoc > 0 && dotLoc > 0 && len > dotLoc+2){
return true;
}else{
alert("Please input a valid Email Address");
document.survey.email.focus();
return false;
}
}
function validateNumber(){
var theNumbersOnly = "";
var theChar = "";
var theInput = document.survey.phone.value;
for (i = 0; i < theInput.length; i++){
theChar = theInput.substring(i,i+1);
if (theChar >= "0" && theChar <= "9"){
theNumbersOnly = "" + theNumbersOnly + theChar;
}
if (document.survey.phone.value < 13){
alert("You must enter 13 numbers.");
document.survey.phone.focus();
}
else{
var countrycode = theNumbersOnly.substring(0,2);
var area = theNumbersOnly.substring(2,5);
var exchange = theNumbersOnly.substring(5,9);
var extension = theNumbersOnly.substring(9,13);
var newNumber = "(" + countrycode + ") ";
newNumber += area + " " + exchange + " " + extension;
document.survey.feedbacknum.value = newNumber;
}
}
function validate(){
var degree = "";
var comments = new Array(4);
comments [0] = 'You are competent.';
comments [1] = 'You are educated.';
comments [2] = 'You are highly educated.';
comments [3] = 'You spent too much time in school.';
for (i=0;i< 4;i++){
if (document.survey['degree'+i].checked){
degree = document.survey['degree'+i].value;
}
}
if (degree == ""){
alert("You need to get an education!");
return false;
}else{
return true;
}
}
}
//-->
</script> </head> <body bgcolor="ooccff">
<h1>User Survey</h1>
<form action="" method="post" enctype="text/plain" name="survey" onsubmit="validatename(); return validateemail(); return validate();">
<p>Name: <input type="text" name="visitor" value="" size="40"></p>
<p>Email Address: <input type="text" name="email" value="" size="30"></p>
<p>phone number: <input type="text" name="phone" value="" size="20" onchange="validateNumber();"><p>
<h4>Degrees you have earned (check all that apply):</h4>
<input type="checkbox" name="degree0" value="H.S."> High School
Diploma<br>
<input type="checkbox" name="degree1" value="B.A."> Bachelor's
Degree<br>
<input type="checkbox" name="degree2" value="M.A."> Master's
Degree<br>
<input type="checkbox" name="degree3" value="Ph.D."> Doctorate<br>
<p><input type="submit" value="Send Survey"></p>
<hr>
<p>Feedbacknumber:<br><input type="textarea" name="feedbacknum" value="" size="50"></p>
</form>
</body></html>
[3728 byte] By [
Phil23] at [2007-11-20 5:43:01]

# 2 Re: Outputting form into text area help !
Sorry , not sure how to do that , what i ws hoping wss to be able to get all the fields such as name , email , number and the heck boxes to output there information to a text area at the bottom of the form when the sybmit button is pressed .
<html>
<head>
<title>form</title>
<script type="text/javascript" language="JavaScript">
<!--
function validatename(){
if (!document.survey.visitor.value){
alert("Please enter your name before submitting this form.");
document.survey.visitor.focus();
return false;
}else{
return true;
}
}
function validateemail(){
var theEmail = document.survey.email.value;
var atLoc = theEmail.indexOf("@",1);
var dotLoc = theEmail.indexOf(".",atLoc+2);
var len = theEmail.length;
if (atLoc > 0 && dotLoc > 0 && len > dotLoc+2){
return true;
}else{
alert("Please input a valid Email Address");
document.survey.email.focus();
return false;
}
}
function validateNumber(){
var theNumbersOnly = "";
var theChar = "";
var theInput = document.survey.phone.value;
for (i = 0; i < theInput.length; i++){
theChar = theInput.substring(i,i+1);
if (theChar >= "0" && theChar <= "9"){
theNumbersOnly = "" + theNumbersOnly + theChar;
}
if (document.survey.phone.value < 13){
alert("You must enter 13 numbers.");
document.survey.phone.focus();
}
else{
var countrycode = theNumbersOnly.substring(0,2);
var area = theNumbersOnly.substring(2,5);
var exchange = theNumbersOnly.substring(5,9);
var extension = theNumbersOnly.substring(9,13);
var newNumber = "(" + countrycode + ") ";
newNumber += area + " " + exchange + " " + extension;
document.survey.feedbacknum.value = newNumber;
}
}
function validate(){
var degree = "";
var comments = new Array(4);
comments [0] = 'You are competent.';
comments [1] = 'You are educated.';
comments [2] = 'You are highly educated.';
comments [3] = 'You spent too much time in school.';
for (i=0;i< 4;i++){
if (document.survey['degree'+i].checked){
degree = document.survey['degree'+i].value;
}
}
if (degree == ""){
alert("You need to get an education!");
return false;
}else{
return true;
}
}
}
//-->
</script> </head> <body bgcolor="ooccff">
<h1>User Survey</h1>
<form action="" method="post" enctype="text/plain" name="survey" onsubmit="validatename(); return validateemail(); return validate();">
<p>Name: <input type="text" name="visitor" value="" size="40"></p>
<p>Email Address: <input type="text" name="email" value="" size="30"></p>
<p>phone number: <input type="text" name="phone" value="" size="20" onchange="validateNumber();"><p>
<h4>Degrees you have earned (check all that apply):</h4>
<input type="checkbox" name="degree0" value="H.S."> High School
Diploma<br>
<input type="checkbox" name="degree1" value="B.A."> Bachelor's
Degree<br>
<input type="checkbox" name="degree2" value="M.A."> Master's
Degree<br>
<input type="checkbox" name="degree3" value="Ph.D."> Doctorate<br>
<p><input type="submit" value="Send Survey"></p>
<hr>
<p>Feedbacknumber:<br><input type="textarea" name="feedbacknum" value="" size="50"></p>
</form>
</body></html>