java - Spring MVC - delete row in SQL with JSP table -
i got issue place "delete" buttons in cart (sql table) want in order when cursor on delete button in example row id 36 link in button suitable row's id, 36.
this code:
<form action="/onlineshop/cart/selecteditem=${cart.getid()}" method="post"> <div style="padding-right: 40px"> <table border="1"> <tr> <td>id</td> <td>product</td> <td>name</td> <td>company</td> <td>type</td> <td>price</td> <td>action</td> </tr> <c:foreach var="cart" items="${carts}"> <tr> <td>${cart.getid()}</td> <td><img src="${cart.getproduct()}" /></td> <td>${cart.getname()}</td> <td>${cart.getcompany()}</td> <td>${cart.gettype()}</td> <td>${cart.getprice()}</td> <td><input type="submit" value="delete"/></td> </tr> </c:foreach> </table> </div> </form> i'm not surprised doesn't work wanted (ids doesn't display when cursor on delete because form action doesn't know string?) , tried that:
<c:foreach var="cart" items="${carts}"> <form action="/onlineshop/cart/selecteditem=${cart.getid()}" method="post"> <div style="padding-right: 40px"> <table border="1"> <tr> <td>id</td> <td>product</td> <td>name</td> <td>company</td> <td>type</td> <td>price</td> <td>action</td> </tr> <tr> <td>${cart.getid()}</td> <td><img src="${cart.getproduct()}" /></td> <td>${cart.getname()}</td> <td>${cart.getcompany()}</td> <td>${cart.gettype()}</td> <td>${cart.getprice()}</td> <td><input type="submit" value="delete"/></td> </tr> </table> </div> </form> </c:foreach> it worked exception every row seperated rest rows. it's 1 table (with marked columns) responsible 1 row sql database. how can fix this?
you can in js, can works you:
<div style="padding-right: 40px"> <table border="1"> <tr> <td>id</td> <td>product</td> <td>name</td> <td>company</td> <td>type</td> <td>price</td> <td>action</td> </tr> <c:foreach var="cart" items="${carts}"> <tr> <td>${cart.getid()}</td> <td><img src="${cart.getproduct()}" /></td> <td>${cart.getname()}</td> <td>${cart.getcompany()}</td> <td>${cart.gettype()}</td> <td>${cart.getprice()}</td> <td><form action="/onlineshop/cart/selecteditem=${cart.getid()}" method="post"><input type="submit" value="delete"/></form></td> </tr> </c:foreach> </table> </div>
Comments
Post a Comment