-
Notifications
You must be signed in to change notification settings - Fork 0
/
submit02.js
29 lines (26 loc) · 1.41 KB
/
submit02.js
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
// JavaScript to handle form submission and show the thank you message
document.getElementById("myForm").addEventListener("submit", function(event) {
event.preventDefault(); // Prevent form submission and page reload
// Get form data
const name = document.getElementById("name").value;
const fatherName = document.getElementById("Fathername").value;
const rollNo = document.getElementById("rollno").value;
const dob = document.getElementById("DOB").value;
const institution = document.getElementById("Institution").value;
const gender = document.querySelector('input[name="Gender"]:checked').value;
const course = document.getElementById("course").value;
// Create the thank you message
const message = `
<strong>Name:</strong> ${name} <br>
<strong>Father's Name:</strong> ${fatherName} <br>
<strong>Roll No:</strong> ${rollNo} <br>
<strong>Date of Birth:</strong> ${dob} <br>
<strong>Institution Name:</strong> ${institution} <br>
<strong>Gender:</strong> ${gender.charAt(0).toUpperCase() + gender.slice(1)} <br>
<strong>Course:</strong> ${course}
`;
// Show thank you message and hide form
document.getElementById("myForm").style.display = "none";
document.getElementById("thankYouMessage").style.display = "block";
document.getElementById("submittedDetails").innerHTML = message;
});