forked from Midway91/HactoberFest2023
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.js
53 lines (42 loc) · 1.51 KB
/
app.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
47
48
49
50
51
52
53
var Name = document.getElementById('Name')
var Email = document.getElementById('Email')
var website = document.getElementById('website')
var btn = document.getElementById('btn');
var cards = document.querySelector('.cards');
var Male = document.getElementById('Male')
var Female = document.getElementById('Female')
var html = document.getElementById('html')
var css = document.getElementById('css')
var javascript = document.getElementById('javascript')
var form = document.querySelector('form');
var selectImage;
var image = function (event) {
selectImage = URL.createObjectURL(event.target.files[0]);
};
btn.addEventListener('click', function () {
let checkboxes = document.querySelectorAll('input[type="checkbox"]:checked');
let values = []
checkboxes.forEach((checkbox) => {
values.push(checkbox.value);
});
if (!Name.value || !Email.value || !website.value ) {
alert('ERROR: Please enter all fields! 😔 ')
}
else {
cards.innerHTML += `
<div class="card">
<div class="image">
<img src='${selectImage}' alt="Image">
</div>
<div class="card-body">
<h4 class="title">${Name.value}</h4>
<p class="text">${Male.checked ? Male.value : Female.checked ? Female.value : 'Others'}</p>
<p class="text">${Email.value}</p>
<p class="text">${website.value}</p>
<p class="text">${values}</p>
</div>
</div>`
alert(' Wohoo!! Student Enrolled Successfully!!!! 😁 😄')
form.reset()
}
});