P
patrickbartell
Hi,
What I need to do is to get my form data to display in the webpage
when submit is clicked. I can get the first input box but after that
not the rest. I am trying to loop through all the elements but it just
stops after the first one.
This is my javascript called new.js:
function newText() {
var my_var=document.getElementById("formId");
for (var i=0;i<my_var.length;++i){
document.write(my_var.value + "<br >");
}
}
And this is my form:
<script type="text/javascript" src="new.js"></script>
<form method="post" action="" onsubmit="newText()" id="formId">
<blockquote>
<blockquote>
<table border="0" cellpadding="8" cellspacing="0" width="50%"
style="margin:auto">
<tr>
<td align="right" style="white-space:nowrap">First Name:</td>
<td><input type="text" name="FirstName" size="25" id="formId1"/></td>
</tr>
<tr>
<td align="right" style="white-space:nowrap">Last Name:</td>
<td><input type="text" name="LastName" size="25" id="formId2"/></td>
</tr>
<tr>
<td align="right" style="white-space:nowrap">Poet?</td>
<td>
<input type="radio" name="Poet" value="Yes"/>Yes <input
type="radio" name="Poet" value="No"/>No
</td>
</tr>
<tr>
<td align="right" valign="top" style="white-space:nowrap">Favorite
Poem</td>
<td>
<select name="Poem" size="1">
<option>Paul Revere's Ride</option>
<option>The Day is Done</option>
</select>
</td>
</tr>
<tr>
<td align="right" valign="top" style="white-space:nowrap">Comments</
td>
<td>
<textarea rows="6" name="Comments" cols="29"></textarea></td>
</tr>
<tr>
<td class="center" colspan="2">
<input type="submit" value="Submit Form"/>
<input type="reset" value="Reset Form"/>
</td>
</tr>
</table>
</blockquote>
</blockquote>
</form>
What I need to do is to get my form data to display in the webpage
when submit is clicked. I can get the first input box but after that
not the rest. I am trying to loop through all the elements but it just
stops after the first one.
This is my javascript called new.js:
function newText() {
var my_var=document.getElementById("formId");
for (var i=0;i<my_var.length;++i){
document.write(my_var.value + "<br >");
}
}
And this is my form:
<script type="text/javascript" src="new.js"></script>
<form method="post" action="" onsubmit="newText()" id="formId">
<blockquote>
<blockquote>
<table border="0" cellpadding="8" cellspacing="0" width="50%"
style="margin:auto">
<tr>
<td align="right" style="white-space:nowrap">First Name:</td>
<td><input type="text" name="FirstName" size="25" id="formId1"/></td>
</tr>
<tr>
<td align="right" style="white-space:nowrap">Last Name:</td>
<td><input type="text" name="LastName" size="25" id="formId2"/></td>
</tr>
<tr>
<td align="right" style="white-space:nowrap">Poet?</td>
<td>
<input type="radio" name="Poet" value="Yes"/>Yes <input
type="radio" name="Poet" value="No"/>No
</td>
</tr>
<tr>
<td align="right" valign="top" style="white-space:nowrap">Favorite
Poem</td>
<td>
<select name="Poem" size="1">
<option>Paul Revere's Ride</option>
<option>The Day is Done</option>
</select>
</td>
</tr>
<tr>
<td align="right" valign="top" style="white-space:nowrap">Comments</
td>
<td>
<textarea rows="6" name="Comments" cols="29"></textarea></td>
</tr>
<tr>
<td class="center" colspan="2">
<input type="submit" value="Submit Form"/>
<input type="reset" value="Reset Form"/>
</td>
</tr>
</table>
</blockquote>
</blockquote>
</form>