-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
40 lines (32 loc) · 1.19 KB
/
Copy pathscript.js
File metadata and controls
40 lines (32 loc) · 1.19 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
// ============ MedSetu JavaScript ============
// This adds form data into the patient table dynamically
// Select the form and table body
const form = document.getElementById("registrationForm");
const tableBody = document.querySelector("#userTable tbody");
// Handle form submission
form.addEventListener("submit", function (event) {
event.preventDefault(); // Stop page reload
// Get values from inputs
const name = document.getElementById("name").value;
const gender = document.getElementById("gender").value;
const age = document.getElementById("age").value;
const city = document.getElementById("city").value;
const doctor = document.getElementById("doctor").value;
const date = document.getElementById("date").value;
// Create a new row
const newRow = document.createElement("tr");
newRow.innerHTML = `
<td>${name}</td>
<td>${gender}</td>
<td>${age}</td>
<td>${city}</td>
<td>${doctor}</td>
<td>${date}</td>
`;
// Add the new row to the table
tableBody.appendChild(newRow);
// Show confirmation alert
alert("Appointment successfully booked for " + name + "!");
// Clear form fields
form.reset();
});