eddy
eddy

Reputation: 4413

How to pass data from selected rows using checkboxes from JSP to the server

I'd like to know if there's any way to send data to the server for the selected rows using the checkboxes I've put on those rows? I mean , how can I send only the data of those selected rows to the server?

alt text

Here's the html code I use:

<table>
  <thead>
    <tr class="tableheader">
      <td width="10%"></td>
      <td width="30%">Vehicle</td>
      <td width="40%">Driver</td>
      <td width="10%">Mileage</td>
     </tr>
  </thead>
  <tbody>
    <c:forEach items="${list}" var="item">
         <tr>
             <td align="center">
                <input type="checkbox" name="selectedItems" 
                    value="c:out value="${item.numberPlate}"/>"/>
             </td>
             <td align="left"><c:out value="${item.numberPlate}"/></td>
             <td align="left"><c:out value="${item.driver.fullName}" /></td>
             <td align="left"><input type="text" name="mileage" value="" /></td>
          </tr>
     </c:forEach>                       
   </tbody>
</table>

I really hope you can give some guidance on this.

Thanks in beforehand.

Upvotes: 1

Views: 3623

Answers (1)

Bozho
Bozho

Reputation: 597056

When handling the request use request.getParameterValues("selectedItems"). And I don't think it's needed to add [] to names

Upvotes: 1

Related Questions