Widget:Test
Ir para navegação
Ir para pesquisar
<!DOCTYPE html> <html lang="pt-BR"> <head>
<meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>Seleção e Exibição de Imagens</title> <style> .hidden { display: none; } .image-container img { width: 100px; height: 100px; margin: 5px; } </style>
</head> <body>
Selecione o Tipo de Mapa
<form id="mapForm">
<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>
</form>
<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 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>
</body> </html>