0

I am having a table in a form, table has 6 cells of each row having checkboxes in it. when i click on the submit button changes made to each checkboxes needs to updated in DB.table generated dynamically.

steps i followed is,

after submitting form, retrieve all the cell values of table and update db accordingly. but now for the checkboxes which are not checked, value stored is nothing. is there any other way around to achieve the same?

Servlet:

out.print("<table id=prev class=display nowrap stripe row-border order-column>");
   out.print("<thead>");
   out.print("<tr>" +
"<th>Form Id</th>\n" +
"                <th>Form Name</th>\n" +
"                <th>Open</th>\n" +
"                <th>Report</th>\n" +
"                <th>View</th>\n" +
"                <th>Insert</th>\n" +
"                <th>Update</th>\n" +
"                <th>Delete</th>\n" +
"                <th>Approve Transaction</th>\n" +
"                <th>Reject Transaction</th>\n" +
"                   </tr>");
   out.print("</thead>");
    out.print("<tfoot>");
   out.print("<tr>" +
"<th>Form Id</th>\n" +
"                <th>Form Name</th>\n" +
"                <th>Open</th>\n" +
"                <th>Report</th>\n" +
"                <th>View</th>\n" +
"                <th>Insert</th>\n" +
"                <th>Update</th>\n" +
"                <th>Delete</th>\n" +
"                <th>Approve Transaction</th>\n" +
"                <th>Reject Transaction</th>\n" +
"                   </tr>");
   out.print("</tfoot>");
   out.println("<tbody>");
 while(rs1.next())
    {out.print("<tr><td name=prvlg>"+rs1.getInt("FORM_ID")+"</td>"
           + "<td name=prvlg>"+rs1.getString("FORM_NAME")+"</td>");
   if(form1==1){ out.print("<td name=prvlg><input type=checkbox checked=checked></td>");}
   else { out.print("<td name=prvlg><input type=checkbox></td>");}
   if(report==1)
       { out.print("<td name=prvlg><input type=checkbox checked=checked></td>");}
   else { out.print("<td name=prvlg><input type=checkbox></td>");}
   if(view==1)
       { out.print("<td name=prvlg><input type=checkbox checked=checked></td>");}
   else { out.print("<td name=prvlg><input type=checkbox></td>");}
    if(insert1==1)
       { out.print("<td name=prvlg><input type=checkbox checked=checked></td>");}
   else { out.print("<td name=prvlg><input type=checkbox></td>");}
     if(update==1)
       { out.print("<td name=prvlg><input type=checkbox checked=checked></td>");}
   else { out.print("<td name=prvlg><input type=checkbox></td>");}
      if(delete==1)
       { out.print("<td name=prvlg><input type=checkbox checked=checked></td>");}
   else { out.print("<td name=prvlg><input type=checkbox></td>");}
       if(isapproved==1)
       { out.print("<td name=prvlg><input type=checkbox checked=checked></td>");}
   else { out.print("<td name=prvlg><input type=checkbox></td>");}
       if(not_approved==1)
       { out.print("<td name=prvlg><input type=checkbox checked=checked></td>");}
   else { out.print("<td name=prvlg><input type=checkbox></td>");}

   }
   out.print("</tbody></table>");
}

and displaying it as here:

 if ((zreq.readyState == 4) && (zreq.status == 200)) {

                            document.getElementById("user_prev").innerHTML = zreq.responseText;
                           $("#parent").DataTable({
                               dom: 't',
                           });


String td[]=request.getParameterValues("prvlg");

it is always null. Can anyone suggest me where i am going wrong?

techhunter
  • 683
  • 1
  • 12
  • 27
  • http://stackoverflow.com/questions/11424037/does-input-type-checkbox-only-post-data-if-its-checked - checkboxes that are not checked are not submitted. Your back end code needs to handle that. – stdunbar Dec 13 '16 at 19:47
  • Thanks for the quick response . – techhunter Dec 14 '16 at 05:05

0 Answers0