-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathHome.js
72 lines (55 loc) · 1.82 KB
/
Home.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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
var firstName = document.getElementById("firstName");
var LastName = document.getElementById("LastName");
var Email = document.getElementById("Email");
var Mobile = document.getElementById("mobile");
var Github = document.getElementById("github");
var Contribution = document.getElementById("contro");
var pullReq = document.getElementById("pull");
var Linkedin = document.getElementById("Linkedin");
const form = document.getElementById("form");
var Profession = document.getElementById("Profession");
var selectedElement = Profession.options[Profession.selectedIndex].text;
const toast = document.querySelector(".toast");
// function for gender checking
function genderCheck() {
var gender = " ";
if (document.getElementById("male").checked) {
gender = document.getElementById("male").value;
}
if (document.getElementById("female").checked) {
gender = document.getElementById("female").value;
}
return gender;
}
// On submit function
form.addEventListener("submit", (e) => {
e.preventDefault();
// creating object for storing form data
let data = {
FirstName: firstName.value,
LastName: LastName.value,
Email: Email.value,
GithubId: Github.value,
Contribution: Contribution.value,
PullRequest: pullReq.value,
linkedin: Linkedin.value,
Gender: genderCheck(),
Profession: selectedElement,
};
// converting this object to json
const jsondata = JSON.stringify(data);
// loging the form data in json format on console
console.log(jsondata);
// Clearing value of input filed after submiting
firstName.value = "";
LastName.value = "";
Email.value = "";
Github.value = "";
Contribution.value = "";
pullReq.value = "";
Linkedin.value = "";
Mobile.value = "";
// toast part
const toastBootstrap = bootstrap.Toast.getOrCreateInstance(toast);
toastBootstrap.show();
});