I can show the values in a database, with a checkbox, but can't retrieve rows I checked

When I submit, the only response that I get is the first row, event that I have checked everyone

Here my code

            <table border="1" align="center" valign="center">
                <c:forEach var="row" items="${parcelas.rows}">

                    <form>
                        <td>
                            <input type="checkbox" name="id" value="${row.parcelaID}" >
                        </td>
                    </form>
                    <td><c:out value="${row.parcelaID}"/></td>
                    <td><c:out value="${row.parcelaVencimento}"/></td>
                    <td ><c:out value="${row.parcelaValor}"/></td>
                    <td><c:out value="${row.clienteID}"/></td>

                    <tr></tr>


                </c:forEach>

            </table>
  <input type="submit" value="OK" />

        </form>



<c:forEach var="row" items="${param.id}">
    <c:out value="${row}"/><br/>
</c:forEach>

Recommended Answers

All 3 Replies

Try a query on the table using the WHERE command on the checkbox field:

SELECT *
FROM Table1
WHERE (((Table1.Checkbox)=True));

Hope that helps solve your problem.

Thanks

Only for not getting me wrong, you mean a select in the HTML table and not the database table .

Correct ?

Your resulting code is not valid HTML.
You have multiple form tags and the submit button sends only the data of the first form.

Open and close the <form> tag only once and outside of the <c:forEach>.

Also, it's good practice to give the form an id so that you can refer to it easily (if you use javascript/DOM) and distinguish it from other forms that may exist in the same page.
e.g.

<form id="myform" action="#" method="post">...</form>
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.