document.getElementById("studentForm").addEventListener("submit", function(event) {
event.preventDefault(); // Prevent form submission
// Get form input values
var name = document.getElementById("nameInput").value;
var rollNumber = document.getElementById("rollNumberInput").value;
var profilePicture = document.getElementById("profilePictureInput").files[0];
// Display submitted data using callback function
displayStudentData(name, rollNumber, profilePicture, function() {
// Callback function: executed after displaying student data
// Additional actions can be performed here if needed
console.log("Student data displayed!");
});
});
function displayStudentData(name, rollNumber, profilePicture, callback) {
// Display student details and photo
document.getElementById("name").textContent = name;
document.getElementById("rollNumber").textContent = rollNumber;
var profilePictureElement = document.getElementById("profilePicture");
profilePictureElement.src = URL.createObjectURL(profilePicture);
profilePictureElement.style.display = "block";
// Hide the form
document.getElementById("studentForm").style.display = "none";
document.getElementById("submittedData").style.display = "block";
// Execute callback function (if provided)
if (typeof callback === "function") {
callback();
}
}