Skip to content

Commit 3962f22

Browse files
committed
feat (type): insertion of extra field in others
Only if it is necessary to create a new optional type
1 parent 3c2f6b2 commit 3962f22

1 file changed

Lines changed: 25 additions & 1 deletion

File tree

assets/script/index.js

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,28 @@ var summary = document.querySelector('body > main > section#summary');
44
var body = document.querySelector('body > main > section#body');
55
var footer = document.querySelector('body > main > section#footer');
66
var significantChange = document.querySelector('body > main > section#significantChange');
7-
var result = document.querySelector('body > main > section#result');
7+
var result = document.querySelector('body > main > section#result');
8+
9+
10+
for (let checkBox of type.querySelectorAll('form > div > label > input')) {
11+
12+
checkBox.onchange = function() {
13+
14+
if (this.value == 'other') {
15+
16+
if (!type.querySelector('form > div > label[for="other"] > span > input')) {
17+
18+
type.querySelector('form > div > label[for="other"] > span').innerHTML = '<input type="text" name="otherType" pattern="[a-zA-Z]+" placeholder="Insert the new type" required>';
19+
type.querySelector('form > div > label[for="other"] > span > input').focus();
20+
21+
}
22+
23+
} else {
24+
25+
type.querySelector('form > div > label[for="other"] > span').innerHTML = "<strong>other</strong>: Doesn't fit any of the suggested types?";
26+
27+
}
28+
29+
};
30+
31+
}

0 commit comments

Comments
 (0)