-
Notifications
You must be signed in to change notification settings - Fork 68
/
index.js
46 lines (35 loc) · 1.46 KB
/
index.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
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
document.addEventListener('DOMContentLoaded', function () {
const cardForm = document.getElementById('cardForm');
const modal = document.getElementById('modal');
const certificateContent = document.getElementById('certificateContent');
const closeModal = document.querySelector('.close');
// Hide the modal initially
modal.style.display = 'none';
cardForm.addEventListener('submit', function (e) {
e.preventDefault();
// 🚨 Get input values
const studentNameInput = document.getElementById('studentName');
const personalMessageInput = ;
const courseNameInput = ;
const studentName = studentNameInput.value;
const personalMessage = personalMessageInput.value;
const courseName = courseNameInput ? courseNameInput.value : "a course"; // Fallback to "a course" if no input
if (studentName.trim() === '' || personalMessage.trim() === '') {
alert('Please fill in all fields');
return;
}
// 🚨 Generate certificate content dynamically
certificateContent. = `
<h3>${studentName}</h3>
`;
// Display the modal
modal.style.display = 'block';
// Clear the form inputs
studentNameInput.value = '';
personalMessageInput.value = '';
if(courseNameInput) courseNameInput.value = '';
});
// 🚨 Close the modal when the close button is clicked
closeModal.('', function () {
});
});