• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 171
  • Last Modified:

Servlets & Checkboxes

I have a servlet that creates dynamic html with rows in a table, each row has a check box so the row can be selected.  The user can select any or all of the check boxed rows.

How do I pass and then find out which rows where checked in the next servlet that is called?

Thank you in advance.
0
suzuki
Asked:
suzuki
1 Solution
 
Rich6176Commented:
  When the checkbox is created by the original servlet make sure the name and values are unique for each element. Say for instance the first checkbox of the first row could have it's name set to A1, next A2, A3, etc..... When the form is then submitted only the names and values of the checked checkboxes will be returned then you can sort the name and value of the parameters sent to construct the next .html file.
Try this code if your having trouble with parameters

private void getParams(HttpServletRequest req)
{
      Enumeration enum = req.getParameterNames();
      String value;
      String name;
      
      while (enum.hasMoreElements());
      {
            name = (String)enum.nextElement();
            value = req.getParameter(name);
            System.out.println(name + " = " + value);

            if (name.equals("A1"))
                this.firstCheckboxClicked();
      }
}
0

Featured Post

Prep for the ITIL® Foundation Certification Exam

December’s Course of the Month is now available! Enroll to learn ITIL® Foundation best practices for delivering IT services effectively and efficiently.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now