COMPLETE FORM 10/19/24
by jimkennelly
HTML
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link href="https://stackpath.bootstrapcdn.com/bootstrap/4.5.2/css/bootstrap.min.css" rel="stylesheet">
<title>Incident Report Form</title>
</head>
<body>
<div class="container">
<h2 class="mt-4">Incident Report Form</h2>
<!-- Progress Bar -->
<div class="progress mb-4">
<div id="progressBar" class="progress-bar" role="progressbar" style="width: 20%;" aria-valuenow="20" aria-valuemin="0" aria-valuemax="100">Step 1 of 5</div>
</div>
<form id="incidentReportForm">
<!-- Page 1: People Involved -->
<div class="page active" id="page1">
<h3>Employee Information</h3>
<div class="form-group">
<label for="firstName">First Name</label>
<input type="text" class="form-control" id="firstName" required>
</div>
<div class="form-group">
<label for="lastName">Last Name</label>
<input type="text" class="form-control" id="lastName" required>
</div>
<div class="form-group">
<label for="department">Department Assigned</label>
<input type="text" class="form-control" id="department" required>
</div>
<div class="form-group">
<label for="title">Title</label>
<input type="text" class="form-control" id="title" required>
</div>
<button type="button" class="btn btn-primary" onclick="nextPage(1)">Next</button>
</div>
<!-- Page 2: Person Completing Report -->
<div class="page" id="page2">
<h3>Report Completion</h3>
<div class="form-group">
<label for="reporterName">Name of Person Completing the Report</label>
<input type="text" class="form-control" id="reporterName"...
CSS
.page {
display: none;
}
.active {
display: block;
}
.hidden {
display: none;
}
JavaScript
let currentPage = 1;
function updateProgress() {
const progressBar = document.getElementById('progressBar');
const progressPercentage = (currentPage / 5) * 100;
progressBar.style.width = `${progressPercentage}%`;
progressBar.setAttribute('aria-valuenow', progressPercentage);
progressBar.innerText = `Step ${currentPage} of 5`;
}
function nextPage(page) {
document.querySelector( "form" ).reportValidity();
document.getElementById(`page${page}`).classList.remove('active');
currentPage++;
document.getElementById(`page${currentPage}`).classList.add('active');
updateProgress();
}
function prevPage(page) {
document.getElementById(`page${page}`).classList.remove('active');
currentPage--;
document.getElementById(`page${currentPage}`).classList.add('active');
updateProgress();
}
function showIncidentDetails() {
const incidentType = document.getElementById('incidentType').value;
const detailsDiv = document.getElementById('incidentDetails');
detailsDiv.innerHTML = ''; // Clear previous content
$("#handled").hide();
$("#struckAgainstHTML").hide();
$("#struckByHTML").hide();
$("#caughtBetweenHTML").hide();
$("#fallSameHTML").hide();
$("#fallDiffHTML").hide();
$("#contactWithHTML").hide();
$("#droveAndStruckByHTML").hide();
$("#droveAndLostControlHTML").hide();
switch (incidentType) {
case 'handled':
$("#handled").show();
break;
case 'struckAgainst':
$("#struckAgainstHTML").show();
break;
case 'struckBy':
$("#struckByHTML").show();
break;
case 'caughtBetween':
$("#caughtBetweenHTML").show();
break;
case 'fallSame':
...