function addPatient() {
// Get form values
const name = document.getElementById('name').value;
const hospitalNumber = document.getElementById('hospitalNumber').value;
const eye = document.getElementById('eye').value;
const procedure = document.getElementById('procedure').value;
const gap = document.getElementById('gap').value;
const lastInjection = document.getElementById('lastInjection').value;
const bloodThinner = document.getElementById('bloodThinner').value;
const transport = document.getElementById('transport').value;
const wheelchair = document.getElementById('wheelchair').value;
// Debugging: Log the retrieved values
console.log('Adding patient:', {
name, hospitalNumber, eye, procedure, gap, lastInjection, bloodThinner, transport, wheelchair
});
// Create a new row and cells
const table = document.getElementById('patientTable').getElementsByTagName('tbody')[0];
const newRow = table.insertRow();
const nameCell = newRow.insertCell(0);
const hospitalNumberCell = newRow.insertCell(1);
const eyeCell = newRow.insertCell(2);
const procedureCell = newRow.insertCell(3);
const gapCell = newRow.insertCell(4);
const lastInjectionCell = newRow.insertCell(5);
const bloodThinnerCell = newRow.insertCell(6);
const transportCell = newRow.insertCell(7);
const wheelchairCell = newRow.insertCell(8);
// Fill cells with form data
nameCell.textContent = name;
hospitalNumberCell.textContent = hospitalNumber;
eyeCell.textContent = eye;
procedureCell.textContent = procedure;
gapCell.textContent = gap;
lastInjectionCell.textContent = lastInjection;
bloodThinnerCell.textContent = bloodThinner;
transportCell.textContent = transport;
wheelchairCell.textContent = wheelchair;
// Clear the form
document.getElementById('patientForm').reset();
}
body {
font-family: Arial, sans-serif;
}
h1, h2 {
text-align: center;
}
form {
margin: 20px auto;
width: 300px;
padding: 10px;
border: 1px solid #ccc;
border-radius: 5px;
}
label {
display: inline-block;
width: 120px;
}
input {
width: calc(100% - 130px);
}
button {
display: block;
margin: 10px auto;
padding: 5px 10px;
}
table {
margin: 20px auto;
width: 90%;
border-collapse: collapse;
}
table, th, td {
border: 1px solid #ccc;
}
th, td {
padding: 10px;
text-align: center;
}
Inj Test
body {
font-family: Arial, sans-serif;
}
h1, h2 {
text-align: center;
}
form {
margin: 20px auto;
width: 300px;
padding: 10px;
border: 1px solid #ccc;
border-radius: 5px;
}
label {
display: inline-block;
width: 120px;
}
input {
width: calc(100% - 130px);
}
button {
display: block;
margin: 10px auto;
padding: 5px 10px;
}
table {
margin: 20px auto;
width: 90%;
border-collapse: collapse;
}
table, th, td {
border: 1px solid #ccc;
}
th, td {
padding: 10px;
text-align: center;
}
function addPatient() {
// Get form values
const name = document.getElementById('name').value;
const hospitalNumber = document.getElementById('hospitalNumber').value;
const eye = document.getElementById('eye').value;
const procedure = document.getElementById('procedure').value;
const gap = document.getElementById('gap').value;
const lastInjection = document.getElementById('lastInjection').value;
const bloodThinner = document.getElementById('bloodThinner').value;
const transport = document.getElementById('transport').value;
const wheelchair = document.getElementById('wheelchair').value;
// Debugging: Log the retrieved values
console.log('Adding patient:', {
name, hospitalNumber, eye, procedure, gap, lastInjection, bloodThinner, transport, wheelchair
});
// Create a new row and cells
const table = document.getElementById('patientTable').getElementsByTagName('tbody')[0];
const newRow = table.insertRow();
const nameCell = newRow.insertCell(0);
const hospitalNumberCell = newRow.insertCell(1);
const eyeCell = newRow.insertCell(2);
const procedureCell = newRow.insertCell(3);
const gapCell = newRow.insertCell(4);
const lastInjectionCell = newRow.insertCell(5);
const bloodThinnerCell = newRow.insertCell(6);
const transportCell = newRow.insertCell(7);
const wheelchairCell = newRow.insertCell(8);
// Fill cells with form data
nameCell.textContent = name;
hospitalNumberCell.textContent = hospitalNumber;
eyeCell.textContent = eye;
procedureCell.textContent = procedure;
gapCell.textContent = gap;
lastInjectionCell.textContent = lastInjection;
bloodThinnerCell.textContent = bloodThinner;
transportCell.textContent = transport;
wheelchairCell.textContent = wheelchair;
// Clear the form
document.getElementById('patientForm').reset();
}