5 667
edições
Sem resumo de edição |
Sem resumo de edição |
||
Linha 4: | Linha 4: | ||
<meta charset="UTF-8"> | <meta charset="UTF-8"> | ||
<meta name="viewport" content="width=device-width, initial-scale=1.0"> | <meta name="viewport" content="width=device-width, initial-scale=1.0"> | ||
<title> | <title>Seleção e Exibição de Imagens</title> | ||
<style> | <style> | ||
. | .hidden { | ||
display: none; | |||
} | } | ||
.image-container img { | |||
width: 100px; | |||
height: 100px; | |||
margin: 5px; | |||
. | |||
width: | |||
height: | |||
} | } | ||
</style> | </style> | ||
</head> | </head> | ||
<body> | <body> | ||
< | <h1>Selecione o Tipo de Mapa</h1> | ||
< | <form id="mapForm"> | ||
<div id="mapTypeSelection"> | |||
<label><input type="radio" name="mapType" value="1" class="map-type"> Tipo de Mapa 1</label> | |||
<label><input type="radio" name="mapType" value="2" class="map-type"> Tipo de Mapa 2</label> | |||
<label><input type="radio" name="mapType" value="3" class="map-type"> Tipo de Mapa 3</label> | |||
</div> | |||
<div id="specificOptions" class="hidden"> | |||
<!-- Opções específicas aparecerão aqui --> | |||
</div> | |||
<div id="imageContainer" class="image-container hidden"> | |||
<!-- As imagens filtradas serão exibidas aqui --> | |||
</div> | |||
</form> | |||
const | <script> | ||
const specificOptions = { | |||
1: ['Option 1-1', 'Option 1-2', 'Option 1-3'], | |||
2: ['Option 2-1', 'Option 2-2', 'Option 2-3', 'Option 2-4'], | |||
3: ['Option 3-1', 'Option 3-2'] | |||
}; | }; | ||
const | const images = { | ||
'Option 1-1': 'https://wiki.pokexgames.com/images/b/bc/BagOfPollem.png', | |||
'Option 1-2': 'https://wiki.pokexgames.com/images/4/43/AnotherImage.png', | |||
'Option 1-3': 'https://wiki.pokexgames.com/images/3/34/DifferentImage.png', | |||
'Option 2-1': 'https://wiki.pokexgames.com/images/c/c4/ExampleImage.png', | |||
'Option 2-2': 'https://wiki.pokexgames.com/images/5/56/AnotherExample.png', | |||
'Option 2-3': 'https://wiki.pokexgames.com/images/a/a6/SampleImage.png', | |||
'Option 2-4': 'https://wiki.pokexgames.com/images/d/d7/FinalExample.png', | |||
'Option 3-1': 'https://wiki.pokexgames.com/images/e/e8/MapType3Option1.png', | |||
'Option 3-2': 'https://wiki.pokexgames.com/images/f/f9/MapType3Option2.png' | |||
}; | |||
document.querySelectorAll('.map-type').forEach(radio => { | |||
radio.addEventListener('change', function() { | |||
const selectedMapType = this.value; | |||
const optionsDiv = document.getElementById('specificOptions'); | |||
const imageContainer = document.getElementById('imageContainer'); | |||
optionsDiv.innerHTML = ''; | |||
imageContainer.innerHTML = ''; | |||
if (selectedMapType) { | |||
const options = specificOptions[selectedMapType]; | |||
options.forEach(option => { | |||
optionsDiv.innerHTML += ` | |||
<label> | |||
<input type="radio" name="specificOption" value="${option}" class="specific-option"> ${option} | |||
</label> | |||
`; | |||
}); | |||
optionsDiv.classList.remove('hidden'); | |||
} | } | ||
imageContainer.classList.add('hidden'); | |||
}); | |||
}); | |||
document.getElementById('specificOptions').addEventListener('change', function() { | |||
const selectedOption = document.querySelector('input[name="specificOption"]:checked'); | |||
const imageContainer = document.getElementById('imageContainer'); | |||
imageContainer.innerHTML = ''; | |||
if (selectedOption) { | |||
const optionValue = selectedOption.value; | |||
if (images[optionValue]) { | |||
imageContainer.innerHTML = `<img src="${images[optionValue]}" alt="${optionValue}">`; | |||
imageContainer.classList.remove('hidden'); | |||
} | } | ||
} | } | ||
}); | }); | ||
</script> | </script> | ||
</body> | </body> | ||
</html> | </html> |