-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcylinderSelect.js
73 lines (72 loc) · 2.79 KB
/
cylinderSelect.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
function listCylinders() {
let display = document.getElementById("displayCyl");
let valid = false; // We assume this isn't valid
// You can move this outside of the loop, and trim in case the user entered spaces
let cylCompare = document.getElementById("cylEnter").value.toUpperCase().trim();
for (var i = 0; i < cylArray.length; i++) {
if (cylCompare == cylArray[i].name) {
valid = true; // We find a match in one of our array items, so it's valid
display.innerHTML = display.innerHTML + cylArray[i].name + ":" + "<br>" + cylArray[i].brand +
"<br>" + cylArray[i].cylinder + "<br>" + cylArray[i].pins + "<br>" + cylArray[i].type;
}
}
if(!valid) alert("Enter a valid cylinder type"); // If we never found a match then we alert
}
function inValidAlert(){
let cylFindInvalid = document.getElementById("cylEnter").value.toUpperCase();
if(cylFindInvalid != cylArray.name){
let displayIt = document.getElementById("displayCyl");
displayIt.innerHTML = displayIt.innerHTML + "Enter a valid cylinder type";
}
}
//function used to disable the button after it is used once.
const setbutton = document.getElementById('button1');
setbutton.addEventListener('click', disableButton);
function disableButton() {
setbutton.disabled = true;
}
//function that will clear the form as well as the display when clicked.
function clearCyl() {
const cylDisplay = document.getElementById("displayCyl");
document.getElementById("cylForm").reset();
cylDisplay.innerHTML = "";
setbutton.disabled = false;
}
//cylinder type properties shown as individual objects inside of an array.
const cylArray = [
{
name: 'LD',
brand: 'Schlage, Falcon',
cylinder: ' Without cylinder',
pins: ' 6 Pin',
type: ' KIL'
},
{
name: 'RD',
brand: 'Schlage-Everest 29 S123 (Standard)',
cylinder: ' With cylinder',
pins: ' 6 Pin',
type: ' FSIC'
},
{
name: 'PD',
brand: 'Schlage-Everest 29 S123 (Standard)',
cylinder: ' With cylinder',
pins: ' 6 Pin',
type: ' KIL'
},
{
name: 'JD',
brand: 'Schlage',
cylinder: ' Without cylinder',
pins: ' 6 Pin',
type: ' FSIC'
},
{
name: 'GD',
brand: 'Schlage-Everest 29 R Family keyways',
cylinder: ' With cylinder',
pins: ' 7 Pin',
type: ' SFIC'
}
];