I have an HTML form with drop down boxes, check boxes and text fields.
I am looking for a solution that returns the values of the form using javascript.
In other words, javascript must read the form and return the field names and values entered.
Return string should be something similar to the below:
ans00441, 908, txt00441, "I do not know yet", ans00442, "country 2", ans00442, "country 3", ans00442, "country 4", ans00444, "Very Much", txt00444, "Too much"
FORM1 below has been submitted as example.
Any suggestion would be highly appreciated.
FORM1
<SCRIPT LANGUAGE="JavaScript">
function showResult(frm){
alert('Display field names and values');
}
</SCRIPT>
<table>
<tr>
<td>
<h2 id="qst00441">For who will you vote</h2>
<br>
<input type="radio" name="ans00441" value="908 ">Party 1<br>
<input type="radio" name="ans00441" value="909 ">Party 2<br>
<input type="radio" name="ans00441" value="910 ">Party 3<br>
<input type="radio" name="ans00441" value="911 ">Party 4<br>
<br>Other Party<input type="text" name="txt00441" size="45" value="" ><br>
</td>
</tr>
<tr>
<td>
<h2 id="qst00442">Where do you live</h2>
<br>
<input type="checkbox" name="ans00442" value="912 ">Country 1<br>
<input type="checkbox" name="ans00442" value="913 ">Country 2<br>
<input type="checkbox" name="ans00442" value="914 ">Country 3<br>
<input type="checkbox" name="ans00442" value="915 ">Country 4<br>
<br>Other country <input type="text" name="txt00442" size="45" value="" ><br>
</td>
</tr>
<tr>
<td>
<h2 id="qst00444">How much do you earn</h2>
<br>
<input type="radio" name="ans00444" value="921 ">Not to much<br>
<input type="radio" name="ans00444" value="922 ">ok<br>
<input type="radio" name="ans00444" value="923 ">Very Much<br>
<br>Income <input type="text" name="txt00444" size="45" value="" ><br>
</td>
</tr>
</table>
<INPUT TYPE="Button" VALUE="Submit" name="btnSubmit1" onClick="showResult(this.form);"