-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathnextpage.js
28 lines (27 loc) · 1.11 KB
/
nextpage.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
document.addEventListener("DOMContentLoaded", function () {
const retrieveCookieButton = document.getElementById("retrieveCookie");
retrieveCookieButton.addEventListener("click", function () {
const mobileNumber = document.getElementById("mobileNumber").value;
const studentCookie = getCookie("student");
if (studentCookie) {
const student = JSON.parse(studentCookie);
if (student.mobile === mobileNumber) {
alert(`Student Details:\nName: ${student.name}\nDate of Birth: ${student.dob}\nMobile Number: ${student.mobile}\nEmail ID: ${student.email}`);
} else {
alert("Student details not found for the provided mobile number.");
}
} else {
alert("No student details found.");
}
});
});
function getCookie(name) {
const cookies = document.cookie.split(';');
for (let cookie of cookies) {
const [cookieName, cookieValue] = cookie.split('=');
if (cookieName.trim() === name) {
return cookieValue;
}
}
return null;
}