I'm looking for data table with increment option (Flask project).
This table is for admin managmenet - Create order with selected product and save it.
(Once click on save only the selected product will be transfer to orders page)
I need to do it more efficient because I have like 100 products.
There is 2 main problems:
- The increment only affect the first input
- I don't want copy-paste the td,buttun and input per product..
Ataached my code:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
</head>
<style>
table {
margin-bottom:200px;
border-collapse: collapse;
border-spacing: 0;
width: 100%;
border: 1px solid #ddd;
}
th, td {
text-align: center;
padding: 8px;
}
tr:nth-child(even){background-color: #f2f2f2}
</style>
<body>
<div style="overflow-x:auto;">
<table>
<tr>
<th>Product</th>
<th>Price</th>
<th>Quantity</th>
</tr>
<tr>
<td>Product A</td>
<td>20$</td>
<td><button onclick="decrement()">-</button>
<input id="demoInput" type=number min=0 max=1000 style="text-align:right; width: 15%;">
<button onclick="increment()">+</button>
</tr>
<tr>
<td>Product B</td>
<td>20$</td>
<td><button onclick="decrement()">-</button>
<input id="demoInput" type=number min=0 max=1000 style="text-align:center; width: 15%;">
<button onclick="increment()">+</button>
</td>
</tr>
</table>
</div>
</body>
<script>
function increment() {
document.getElementById('demoInput').stepUp();
}
function decrement() {
document.getElementById('demoInput').stepDown();
}
</script>
</html>