JSFiddle - React, Tailwind, and code Playground
by velo_ninja
HTML
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Production Calculator</title>
<style>
/* Basic styling */
table {
width: 100%;
border-collapse: collapse;
}
th, td {
border: 1px solid #000;
padding: 8px;
text-align: center;
}
input {
width: 80px;
}
</style>
</head>
<body>
<table>
<tr>
<th>Hour</th>
<th>Expected Output</th>
<th>Rejected Pieces</th>
<th>Downtime (minutes)</th>
<th>Good Pieces</th>
</tr>
<tr>
<td>1</td>
<td><input type="number" id="expectedOutput1" /></td>
<td><input type="number" id="rejected1" /></td>
<td><input type="number" id="downtime1" /></td>
<td><span id="goodPieces1">0</span></td>
</tr>
<tr>
<td>2</td>
<td><input type="number" id="expectedOutput2" /></td>
<td><input type="number" id="rejected2" /></td>
<td><input type="number" id="downtime2" /></td>
<td><span id="goodPieces2">0</span></td>
</tr>
<!-- Add more rows as needed -->
</table>
<script>
// Function to update calculations based on inputs
function updateFunction() {
// Retrieve inputs
let expectedOutput1 = parseFloat(document.getElementById('expectedOutput1').value) || 0;
let rejected1 = parseFloat(document.getElementById('rejected1').value) || 0;
let downtime1 = parseFloat(document.getElementById('downtime1').value) || 0;
// Calculate good pieces (for demonstration, using a simple formula)
let goodPieces1 = expectedOutput1 - rejected1;
document.getElementById('goodPieces1').innerText = goodPieces1;
...