-
Notifications
You must be signed in to change notification settings - Fork 0
/
script.js
32 lines (26 loc) · 970 Bytes
/
script.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
let hairStyle = "lgtbh";
let mustacheStyle = "cs";
const radioButtons_hair = document.querySelectorAll('input[name="hair"]');
const radioButtons_mustache = document.querySelectorAll('input[name="mustache"]');
for (const radioButton of radioButtons_hair) {
radioButton.addEventListener('change', showSelectedHair);
}
for (const radioButton of radioButtons_mustache) {
radioButton.addEventListener('change', showSelectedMustache);
}
function showSelectedHair(e) {
console.log(e);
console.log(String(this.value));
hairStyle = String(this.value);
showPreview(hairStyle, mustacheStyle);
}
function showSelectedMustache(e) {
console.log(e);
mustacheStyle = String(this.value);
showPreview(hairStyle, mustacheStyle);
}
function showPreview(h, m) {
console.log(h);
console.log(h + '_' + m + '.png');
document.getElementById('preview').src = String('./img/' + h + '_' + m + '_C.png');
}