0

i am trying to develop Medical billing System using JSPs and Servlets in which there is a page to show stock , stock is shown in tabular form with columns ProductName,Price,ExpiryDate and Quantity , if user wants to update any detail then he can double click on that field and change its value and then submit . so what is was doing for this , i created each row a form and put an update button along each row ,is it good a practice creating so much froms on a page or creating forms this way ? what can be the drawbacks ? what can be the alternative ?

<c:forEach var="product" items="${productList }">
                    <form action="updateStock" role="form" method="post">
                        <div class="form-group">
                            <div class="row">

                                <div class="col-sm-3">
                                    <input type="text" value="${product.name }" readonly="readonly"
                                        class="read" name="prodName">
                                </div>
                                <div class="col-sm-2">
                                    <input type="date" value="${product.expiryDate}"
                                        readonly="readonly" class="read" name="prodExpiryDate">
                                </div>
                                <div class="col-sm-2">
                                    <input type="text" value="${product.quantity}"
                                        readonly="readonly" class="read" name="prodQuantity">
                                </div>
                                <div class="col-sm-3">
                                    <input type="text" value="${product.price}" readonly="readonly"
                                        class="read" name="prodPrice">
                                </div>
                                <div class="col-sm-2">
                                    <input type="submit" name="update" value="update"
                                        id="updateButton">
                                </div>
                                <div>
                                    <input type="hidden" name="prodId"
                                        value="${product.productId }">
                                </div>
                            </div>
                        </div>
                    </form>


                </c:forEach>
Alok Mishra
  • 926
  • 13
  • 39
  • I used to do like this for updating a row in a table, but one good alternative instead of creating a lot of forms would be ajax call.. – The Coder Feb 18 '15 at 05:27
  • Instead of creating many forms , user one form and use ajax for updating the value based on the product id while submitting . – Rajesh Feb 18 '15 at 05:44

1 Answers1

0

Though there is no problem in creating different forms I think the faster approach is to create the row in single page and you can give one update button. You can use Ajax to callback to the same page after clicking on submit button.

Rashmi
  • 271
  • 1
  • 2
  • 11