-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex5.js
57 lines (47 loc) · 2.28 KB
/
index5.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
window.onload = function () {
const urlParams = new URLSearchParams(window.location.search);
const customerIDURL = urlParams.get('customerIDURL');
// console.log(customerIDURL);
const userData = JSON.parse(localStorage.getItem('users'));
// console.log(userData);
const user = userData.find(user => user.customerId === customerIDURL);
// console.log(user);
if (user) {
document.getElementById('cusNameSpan').textContent = user.name;
document.getElementById('cusIdSpan').textContent = user.customerId;
}
console.log(customerIDURL);
const userPolicyData = JSON.parse(localStorage.getItem(customerIDURL));
const userPolicyDataLength = userPolicyData.length - 1;
console.log(userPolicyDataLength);
const userPolicy = userPolicyData[userPolicyDataLength];
const logoutBtn = document.getElementById('logoutBtn');
logoutBtn.addEventListener('click', function () {
// Clear the current session information
localStorage.removeItem('currentSession');
window.location.href = 'login.html';
});
if (userPolicy) {
document.getElementById('pType').textContent = userPolicy.choosePolicy;
document.getElementById('pName').textContent = userPolicy.policyTitle;
document.getElementById('sAssured').textContent = userPolicy.sumAssured;
document.getElementById('pAmount').textContent = userPolicy.premiumAmount;
document.getElementById('pTerm').textContent = userPolicy.policyTerm;
}
}
function selectAnother() {
const urlParams = new URLSearchParams(window.location.search);
const customerIDURL = urlParams.get('customerIDURL');
window.location.href = 'index4.html?customerIDURL=' + customerIDURL;
}
function goHome() {
const urlParams = new URLSearchParams(window.location.search);
const customerIDURL = urlParams.get('customerIDURL');
window.location.href = 'index3.html?customerIDURL=' + customerIDURL;
}
const toHome = document.getElementById('toHome');
toHome.addEventListener('click', function () {
const urlParams = new URLSearchParams(window.location.search);
const customerIDURL = urlParams.get('customerIDURL');
window.location.href = "index3.html?customerIDURL=" + customerIDURL;
});