I have this form whereby I allow users to checked the number of subjects he is interested.
But, I am stuck when I want to parse the parameters into the database.
Hope someone can advise me how.
<td><h3><b>Subjects Interested :</b></h3></td>
<tr> <th>Lower Primary</th>
<td><input type="checkbox" name="txtsubjects" value="English">English
<input type="checkbox" name="txtsubjects" value="Chinese">Chinese
<input type="checkbox" name="txtsubjects" value="Math">Math
<input type="checkbox" name="txtsubjects" value="Science">Science </td>
[/code]
And my partial code for servlet in which I am stuck.
Expand|Select|Wrap|Line Numbers
- strCreateRecordSQL += "(strFullName,strEmail,strAddress,"
- + " strLocation, strContact, strType, strSubjects, "
- + " strFrequency, strTutorspref, stBudget, StrRemarks) VALUES (?,?,?,?,?,?,?,?,?,?,?)";
- ps = con.prepareStatement(strCreateRecordSQL);
- ps.setString(1, strFullName);
- /
- / I need to assign the parameters here and insert the checked boxes by user into a database i have created but I do not how to go about doing it for more than one checked boxes.
- String strSubjects[] = request.getParameterValues("txtsubjects");
- if (strSubjects !=null)
- {
- for(int i = 0; i < strSubjects.length; i++)
- {if (i > 0 )
- }
- }