Create New Item
Item Type
File
Folder
Item Name
Search file in folder and subfolders...
Are you sure want to rename?
File Manager
/
Design
/
Dev tableau
:
table0028.php
Advanced Search
Upload
New Item
Settings
Back
Back Up
Advanced Editor
Save
<!DOCTYPE html> <html lang="fr"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>Tableau HTML</title> <style> .table-container { width: 100%; overflow-x: auto; } table { border-collapse: separate; border-spacing: 0; width: 100%; table-layout: auto; } th, td { padding: 5px; text-align: center; border: 1px solid black; box-sizing: border-box; } .fixed-column { position: sticky; left: 0; background: white; z-index: 2; border-left: 2px solid black; border-right: 1px solid black; padding-left: 10px; padding-right: 10px; width: 222px; min-width: 222px; } .second-fixed-column { position: sticky; left: 222px; background: white; z-index: 2; border-right: 1px solid black; padding-left: 10px; padding-right: 10px; width: 100px; min-width: 100px; } th.fixed-column, th.second-fixed-column { top: 0; z-index: 3; } td:first-child { border-left: 2px solid black; } .active-cell { background-color: green; color: white; } .total-column { background-color: #f0f0f0; pointer-events: none; } .week-odd-header { background-color: #e0f7fa; } .week-even-header { background-color: #ffecb3; } </style> </head> <body> <div class="table-container"> <table id="data-table"> <tr> <th class="fixed-column">Nom</th> <th class="second-fixed-column">Total</th> </tr> </table> <button onclick="addRow()">Ajouter une ligne</button> </div> <script> function addRow() { let table = document.getElementById("data-table"); let row = table.insertRow(-1); let cell1 = row.insertCell(0); cell1.classList.add("fixed-column"); let input = document.createElement("input"); input.type = "text"; cell1.appendChild(input); let cell2 = row.insertCell(1); cell2.classList.add("second-fixed-column", "total-column"); cell2.innerText = "0"; for (let i = 2; i < table.rows[0].cells.length; i++) { let cell = row.insertCell(i); cell.innerText = "0"; cell.onclick = function() { toggleCell(cell, row); }; } } function toggleCell(cell, row) { if (cell.innerText === '0') { cell.innerText = '1'; cell.classList.add('active-cell'); } else { cell.innerText = '0'; cell.classList.remove('active-cell'); } updateTotal(row); } function updateTotal(row) { let total = 0; for (let i = 2; i < row.cells.length; i++) { let cellValue = parseInt(row.cells[i].innerText); if (!isNaN(cellValue)) { total += cellValue; } } row.cells[1].innerText = total; } </script> </body> </html>