-
Notifications
You must be signed in to change notification settings - Fork 0
/
dataentry.js
97 lines (80 loc) · 3.02 KB
/
dataentry.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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
// array
let student = [];
// form page
function formDisplay() {
console.log("formDisplay");
document.getElementById("page-One").hidden = false;
document.getElementById("page-Two").hidden = true;
}
// Add data in form
function addData() {
// dictionary
let information = {};
// inputs
information["firstName"] = document.getElementById("first-name").value;
information["lastName"] = document.getElementById("last-name").value;
information["contactNo"] = document.getElementById("contact-no").value;
information["ageEnter"] = document.getElementById("age").value;
information["education"] = document.getElementById("edu-details").value;
information["birth"] = document.getElementById("birth-date").value;
information["email"] = document.getElementById("email-id").value;
// if(education == graduate){
// document.getElementById("edu-details").value = "Graduare";
// }else{
// document.getElementById("edu-details").value = "PostGraduare";
// }
information["address"] = document.getElementById("address-l").value;
student.push(information);
console.log(student, information);
//clear form data
document.getElementById("first-name").value = "";
document.getElementById("last-name").value = "";
document.getElementById("contact-no").value = "";
document.getElementById("age").value = "";
document.getElementById("edu-details").value = "";
document.getElementById("birth-date").value = "";
document.getElementById("email-id").value = "";
document.getElementById("address-l").value = "";
}
//list page
function listDisplay() {
console.log("listDisplay");
document.getElementById("page-One").hidden = true;
document.getElementById("page-Two").hidden = false;
// calling function
showData();
}
// data show in list
function showData() {
let tableOutput = "<table>";
tableOutput = ['<thead class="table-heading"><tr><th class="row">Student Name</th><th>Contact No</th><th>Age</th><th>DOB</th><th class="row">Email-Id </th><th>Education Details</th><th>Address</th> </tr></thead>']
for (let i = 0; i < student.length; i++) {
let output = student[i];
let outputString =
'<tr><td class="row">' +
output.firstName +
" " +
output.lastName +
'</td><td>' +
output.contactNo +
'</td><td>' +
output.ageEnter +
'</td><td>' +
output.birth +
'</td><td class="row">' +
output.email +
'</td><td>' +
output.education +
'</td><td>' +
output.address +
'</td></tr>';
tableOutput += outputString;
console.log("addData", output);
}
tableOutput += "</table>";
document.getElementById("show-info").innerHTML = tableOutput;
}
// first page show
window.onload = function () {
formDisplay();
}