-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
78 lines (61 loc) · 2.79 KB
/
index.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
let modalInfo =[];
const modalName = document.getElementById(`modalName`);
const modalEmail = document.getElementById(`modalEmail`);
const modalText = document.getElementById(`modalText`);
function captureModal(){
let contactInfo = {
id: Math.floor(Math.random() * 1000000),
modalName : modalName.value,
modalEmail : modalEmail.value,
modalText : modalText.value
};
// created variable for calling out the RequestForm inside the local storage
let storedContacts = localStorage.getItem('RequestForm');
/* created variable for ternary condition parsing a JSON object to text format to Javascript object from the LocalStorage
pushing another object using the variable of contactinfo*/
let contactForms = storedContacts ? JSON.parse(storedContacts) : [];
contactForms.push(contactInfo);
// Store data for setting the item into a RequestForm category
localStorage.setItem(`RequestForm`, JSON.stringify(contactForms));
}
window.onload = function (){
let contactForm = document.getElementById(`contactForm`);
contactForm.onsubmit = captureModal;
};
//input default for data-bs-whatever value
const serviceModal = document.getElementById('serviceRequest')
const serviceModal2 = document.getElementById('serviceRequest2')
const serviceModal3 = document.getElementById('serviceRequest3')
serviceModal.addEventListener('show.bs.modal', event => {
// Button that triggered the modal
const button = event.relatedTarget
// Extract info from data-bs-* attributes
const recipient = button.getAttribute('data-bs-whatever')
// Update the modal's content.
const modalTitle = serviceModal.querySelector('.modal-title')
const modalBodyInput = serviceModal.querySelector('.modal-body input')
modalTitle.textContent = `Request for a ${recipient}`
modalBodyInput.value = recipient
})
serviceModal2.addEventListener('show.bs.modal', event => {
// Button that triggered the modal
const button = event.relatedTarget
// Extract info from data-bs-* attributes
const recipient = button.getAttribute('data-bs-whatever')
// Update the modal's content.
const modalTitle = serviceModal2.querySelector('.modal-title')
const modalBodyInput = serviceModal2.querySelector('.modal-body input')
modalTitle.textContent = `Request for a ${recipient}`
modalBodyInput.value = recipient
})
serviceModal3.addEventListener('show.bs.modal', event => {
// Button that triggered the modal
const button = event.relatedTarget
// Extract info from data-bs-* attributes
const recipient = button.getAttribute('data-bs-whatever')
// Update the modal's content.
const modalTitle = serviceModal3.querySelector('.modal-title')
const modalBodyInput = serviceModal3.querySelector('.modal-body input')
modalTitle.textContent = `Request for a ${recipient}`
modalBodyInput.value = recipient
})