Advertisement
Guest User

Untitled

a guest
Mar 26th, 2017
66
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.66 KB | None | 0 0
  1. <div id="makeOrders">
  2. <table id="myDatatable" class="display datatable">
  3. <thead>
  4. <tr>
  5. <th>Part No</th>
  6. <th>Description</th>
  7. <th>Model No</th>
  8. <th>Available QTY</th>
  9. <th>Tick To Order</th>
  10. <th>Quantity</th>
  11. <!-- <th>Edit</th> -->
  12. </tr>
  13. </thead>
  14. <tbody>
  15. <!-- Iterating over the list sent from Controller -->
  16. <c:forEach var="list" items="${compatibility}">
  17.  
  18. <tr>
  19. <td>${list.partNumber}</td>
  20. <td>${list.itemDescription}</td>
  21. <td>${list.compitableDevice}</td>
  22. <td><input type="text" id="avaliableQuantity"
  23. name="avaliableQuantity" class="form-control" readonly="readonly"
  24. value="${list.quantity}"></td>
  25. <td><input type="checkbox" class="form-group"
  26. id="checkedOrder" name="selectedItem"
  27. value="${list.partNumber},${list.compitableDevice},${list.itemDescription}"></td>
  28. <td><input type="text" id="quantity" name="quantity"
  29. class="form-control" onblur="compareQuantity()" value="" /></td>
  30. </tr>
  31.  
  32. </c:forEach>
  33. </tbody>
  34. </table>
  35.  
  36. </div>
  37.  
  38. <script type="text/javascript">
  39. /*Compare available quantity with entered quantity*/
  40. function compareQuantity() {
  41.  
  42. var ourAvaliableQuantity = document.getElementById("avaliableQuantity").value;
  43. var yourQuantity = document.getElementById("quantity").value;
  44. if ( ourAvaliableQuantity >= yourQuantity ) {
  45. alert("Your quantity (" +yourQuantity+ ") is less or equal to available quantity (" + ourAvaliableQuantity+ ") order.n You can now place your order");
  46. console.log("True,",yourQuantity + " is less than " + ourAvaliableQuantity);
  47. console.log("Place an Order");
  48. }else if(ourAvaliableQuantity < yourQuantity) {
  49. alert("Your order quantity (" +yourQuantity+ ") can not be greater than available quantity (" + ourAvaliableQuantity+ "). n Please enter less quantity");
  50. document.getElementById("quantity").value = "";
  51. console.log("False,",ourAvaliableQuantity + " is small than " + yourQuantity);
  52. console.log("You can not place an order, enter less quantity");
  53. console.log("Enter value between 1 till " +ourAvaliableQuantity+ " not more than " +ourAvaliableQuantity);
  54. }
  55. }
  56. </script>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement