CodeNoob
12-10-2003, 09:47 PM
I'm currently looking to update an array via text fields in a form. Not exactly sure how to tackle this problem. What I want to happen is:
1) User fills out a form and clicks submit
2) The information the gets redisplayed
Currently this is what I have. Please help!
<SCRIPT LANGUAGE="JavaScript">
<!-- HIDE FROM INCOMPATIBLE BROWSERS
var answers = new Array(5);
answers[0] = document.question1.value;
answers[1] = document.form.question2.value;
answers[2] = document.form.question3.value;
answers[3] = document.form.question4.value;
function updateArray(value) {
function displayAnswers() {
document.writeln(answers[0]);
document.writeln(answers[1]);
document.writeln(answers[2]);
document.writeln(answers[3]);
}
// STOP HIDING FROM INCOMPATIBLE BROWSERS -->
</SCRIPT>
</HEAD>
<BODY>
<H1>Questionaire</H1>
<P>Please answer all of the fields below and click on submit when done.</P>
<FORM>
<P><B>1. Name</B></P>
<P><INPUT TYPE="text" NAME=question1 onChange="updateArray(this.value)"><BR></P>
<P><B>2. Address</B></P>
<P><INPUT TYPE="text" NAME=question2><BR></P>
<P><B>3. Occupation</B></P>
<P><INPUT TYPE="text" NAME=question3><BR></P>
<P><B>4. Phone</B></P>
<P><INPUT TYPE="text" NAME=question4><BR></P>
<P><INPUT TYPE=button VALUE="Submit" onClick="displayAnswers();"></P>
</FORM>
1) User fills out a form and clicks submit
2) The information the gets redisplayed
Currently this is what I have. Please help!
<SCRIPT LANGUAGE="JavaScript">
<!-- HIDE FROM INCOMPATIBLE BROWSERS
var answers = new Array(5);
answers[0] = document.question1.value;
answers[1] = document.form.question2.value;
answers[2] = document.form.question3.value;
answers[3] = document.form.question4.value;
function updateArray(value) {
function displayAnswers() {
document.writeln(answers[0]);
document.writeln(answers[1]);
document.writeln(answers[2]);
document.writeln(answers[3]);
}
// STOP HIDING FROM INCOMPATIBLE BROWSERS -->
</SCRIPT>
</HEAD>
<BODY>
<H1>Questionaire</H1>
<P>Please answer all of the fields below and click on submit when done.</P>
<FORM>
<P><B>1. Name</B></P>
<P><INPUT TYPE="text" NAME=question1 onChange="updateArray(this.value)"><BR></P>
<P><B>2. Address</B></P>
<P><INPUT TYPE="text" NAME=question2><BR></P>
<P><B>3. Occupation</B></P>
<P><INPUT TYPE="text" NAME=question3><BR></P>
<P><B>4. Phone</B></P>
<P><INPUT TYPE="text" NAME=question4><BR></P>
<P><INPUT TYPE=button VALUE="Submit" onClick="displayAnswers();"></P>
</FORM>