source: src/main/resources/templates/saleplacefooditems.html@ 8d11f8c

Last change on this file since 8d11f8c was 8d11f8c, checked in by jovanmanchev <jovanmanchev3003@…>, 18 months ago

code added, trial 2

  • Property mode set to 100644
File size: 2.8 KB
RevLine 
[8d11f8c]1<!DOCTYPE html>
2<html lang="en">
3<head>
4
5 <meta charset="UTF-8">
6 <title>Title</title>
7 <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap@4.3.1/dist/css/bootstrap.min.css"
8 integrity="sha384-ggOyR0iXCbMQv3Xipma34MD+dH/1fQ784/j6cY/iJTQUOhcWr7x9JvoRxT2MZw1T" crossorigin="anonymous">
9</head>
10
11<body>
12<nav class="navbar navbar-expand-lg navbar-dark bg-dark" style="height: 55px">
13 <div class="collapse navbar-collapse" id="navbarSupportedContent">
14 <ul class="navbar-nav mr-auto">
15 <li class="nav-item"><a style="color: white; font-weight: bolder; text-decoration: none;"
16 th:href="@{/home}">Врати се назад</a></li>
17 </ul>
18 </div>
19</nav>
20
21<div th:if="${error != null}">
22 <p th:text="${error}"></p>
23</div>
24
25<table class="table">
26 <thead class="thead-light">
27 <tr>
28 <th scope="col">Продукт</th>
29 <th scope="col">Цена</th>
30 <th scope="col">Количина</th>
31 </tr>
32 </thead>
33
34 <tbody>
35 <form th:action="@{'/salePlace/{id}'(id = ${salePlaceId})}" th:method="POST">
36 <tr th:each="foodItem : ${foodItems}">
37 <td>
38 <input hidden th:text="${foodItem.getFoodItemName()}" th:value="${foodItem.getFoodItemId()}"
39 name="foodIds"/>
40 </td>
41 <td>
42 <input hidden th:if="${foodItemStat.index < prices.size()}"
43 th:value="${prices.get(foodItemStat.index).getCost()}"
44 th:text="${prices.get(foodItemStat.index).getCost()}"
45 name="foodPrice" class="cena">
46 </td>
47 <td>
48 <input type="number" name="quantity" class="kolichina">
49 </td>
50 </tr>
51 <tr>
52 <td>
53 <select name="typeOfPayment" id="typeOfPayment">
54 <option value="cash">Во готово</option>
55 <option value="card">Картичка</option>
56 </select>
57 </td>
58 <td>Вкупно: <span id="totalPrice">0</span></td>
59 <td>
60 <input type="submit" value="Направете нарачка">
61 </td>
62 </tr>
63 </form>
64 </tbody>
65</table>
66
67</body>
68<script>
69 const totalPriceSpan = document.querySelector('#totalPrice');
70 const kolichini = document.getElementsByClassName("kolichina");
71 for(let j = 0; j<kolichini.length;j++){
72 kolichini[j].addEventListener('change',handleTotalPrice);
73 }
74 function handleTotalPrice(event){
75 const ceni = document.getElementsByClassName("cena");
76 let total = 0;
77 for(let i = 0; i<kolichini.length;i++){
78 total+=ceni[i].value * kolichini[i].value;
79 }
80 totalPriceSpan.innerHTML = total.toString();
81 }
82</script>
83</html>
Note: See TracBrowser for help on using the repository browser.