I have a servlet with MySQL database in it. It looks like this:
here is the piece of code for it:
out.println("<table id = "main_section" cellspacing="1" bgcolor="red" > ");
out.println ("<tr> ");
out.println("<td >NUMBER</td>");
out.println("<td >PAYMENT</td>");
out.println("<td >RECEIVER</td>");
out.println("<td >VALUE </td>");
out.println("<td >CHECKBOX</td>");
out.println("</tr>");
out.println("<tr>");
for (int i = 0; i < ex.getExpenses().size(); i++) {
out.println("<td > " + ex.getExpenses().get(i) + "</td>");
if (i>0 && (i+1)%4==0) {
out.println("<td><input type="checkbox" name="checkbox"></td>");
out.println("</tr><tr>");
}
}
out.println("</tr>");
What I need to do is to create a submit button that calculates the sum of VALUE of the checked boxes. for instance, if NUMBER 1 and 2 are checked the submit button should give the result of 5577.0 (VALUE 22.0+5555.0). Can anyone please help me with that?
See Question&Answers more detail:os