Widget:Test: mudanças entre as edições
Ir para navegação
Ir para pesquisar
Sem resumo de edição |
Sem resumo de edição |
||
Linha 16: | Linha 16: | ||
select { | select { | ||
margin: 5px; | margin: 5px; | ||
} | |||
.image-info { | |||
margin-top: 10px; | |||
} | } | ||
</style> | </style> | ||
Linha 41: | Linha 44: | ||
<div id="imageContainer" class="image-container hidden"> | <div id="imageContainer" class="image-container hidden"> | ||
<!-- | <!-- A imagem e suas informações serão exibidas aqui --> | ||
</div> | </div> | ||
</form> | </form> | ||
Linha 47: | Linha 50: | ||
<script> | <script> | ||
const specificOptions = { | const specificOptions = { | ||
1: ['Option 1-1', 'Option 1-2', 'Option 1-3'], | 1: [ | ||
2: ['Option 2-1', 'Option 2-2', 'Option 2-3', 'Option 2-4'], | { name: 'Option 1-1', local: 'Pewter', coordinates: '3467, 3743, 6' }, | ||
3: ['Option 3-1', 'Option 3-2'] | { name: 'Option 1-2', local: 'Cerulean', coordinates: '1456, 2345, 4' }, | ||
{ name: 'Option 1-3', local: 'Vermilion', coordinates: '5678, 1234, 5' } | |||
], | |||
2: [ | |||
{ name: 'Option 2-1', local: 'Lavender', coordinates: '6789, 2345, 2' }, | |||
{ name: 'Option 2-2', local: 'Celadon', coordinates: '1234, 5678, 3' }, | |||
{ name: 'Option 2-3', local: 'Fuchsia', coordinates: '4567, 6789, 1' }, | |||
{ name: 'Option 2-4', local: 'Cinnabar', coordinates: '7890, 1234, 6' } | |||
], | |||
3: [ | |||
{ name: 'Option 3-1', local: 'Saffron', coordinates: '3456, 7890, 7' }, | |||
{ name: 'Option 3-2', local: 'Pallet', coordinates: '5678, 1234, 2' } | |||
] | |||
}; | }; | ||
Linha 75: | Linha 90: | ||
const options = specificOptions[selectedMapType]; | const options = specificOptions[selectedMapType]; | ||
options.forEach(option => { | options.forEach(option => { | ||
specificOptionSelect.innerHTML += `<option value="${option}">${option}</option>`; | specificOptionSelect.innerHTML += `<option value="${option.name}">${option.name}</option>`; | ||
}); | }); | ||
Linha 93: | Linha 108: | ||
if (selectedOption) { | if (selectedOption) { | ||
const imageUrl = images[selectedOption]; | const imageUrl = images[selectedOption]; | ||
if (imageUrl) { | const optionInfo = specificOptions[document.getElementById('mapType').value].find(opt => opt.name === selectedOption); | ||
imageContainer.innerHTML = `<img src="${imageUrl}" alt="${selectedOption}">`; | if (imageUrl && optionInfo) { | ||
imageContainer.innerHTML = ` | |||
<img src="${imageUrl}" alt="${selectedOption}"> | |||
<div class="image-info"> | |||
Local: ${optionInfo.local} <br> | |||
Coordenada: ${optionInfo.coordinates} | |||
</div> | |||
`; | |||
imageContainer.classList.remove('hidden'); | imageContainer.classList.remove('hidden'); | ||
} | } |
Edição das 03h23min de 23 de agosto de 2024
<!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; } select { margin: 5px; } .image-info { margin-top: 10px; } </style>
</head> <body>
Selecione o Tipo de Mapa
<form id="mapForm">
<label for="mapType">Tipo de Mapa:</label> <select id="mapType"> <option value="">Selecione um mapa</option> <option value="1">Mapa Vermelho</option> <option value="2">Mapa Verde</option> <option value="3">Mapa Roxo</option> </select>
<label for="specificOption">Opções Específicas:</label> <select id="specificOption"> <option value="">Selecione uma opção</option> </select>
</form>
<script> const specificOptions = { 1: [ { name: 'Option 1-1', local: 'Pewter', coordinates: '3467, 3743, 6' }, { name: 'Option 1-2', local: 'Cerulean', coordinates: '1456, 2345, 4' }, { name: 'Option 1-3', local: 'Vermilion', coordinates: '5678, 1234, 5' } ], 2: [ { name: 'Option 2-1', local: 'Lavender', coordinates: '6789, 2345, 2' }, { name: 'Option 2-2', local: 'Celadon', coordinates: '1234, 5678, 3' }, { name: 'Option 2-3', local: 'Fuchsia', coordinates: '4567, 6789, 1' }, { name: 'Option 2-4', local: 'Cinnabar', coordinates: '7890, 1234, 6' } ], 3: [ { name: 'Option 3-1', local: 'Saffron', coordinates: '3456, 7890, 7' }, { name: 'Option 3-2', local: 'Pallet', coordinates: '5678, 1234, 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.getElementById('mapType').addEventListener('change', function() { const selectedMapType = this.value; const specificOptionSelect = document.getElementById('specificOption'); const imageContainer = document.getElementById('imageContainer'); specificOptionSelect.innerHTML = '<option value="">Selecione uma opção</option>'; imageContainer.innerHTML = ; if (selectedMapType) { const options = specificOptions[selectedMapType]; options.forEach(option => { specificOptionSelect.innerHTML += `<option value="${option.name}">${option.name}</option>`; });
document.getElementById('specificOptions').classList.remove('hidden'); } else { document.getElementById('specificOptions').classList.add('hidden'); document.getElementById('imageContainer').classList.add('hidden'); } });
document.getElementById('specificOption').addEventListener('change', function() { const selectedOption = this.value; const imageContainer = document.getElementById('imageContainer'); imageContainer.innerHTML = ; if (selectedOption) { const imageUrl = images[selectedOption]; const optionInfo = specificOptions[document.getElementById('mapType').value].find(opt => opt.name === selectedOption); if (imageUrl && optionInfo) { imageContainer.innerHTML = ` <img src="${imageUrl}" alt="${selectedOption}">
Local: ${optionInfo.local}
Coordenada: ${optionInfo.coordinates}
`; imageContainer.classList.remove('hidden'); } } else { imageContainer.classList.add('hidden'); } }); </script>
</body> </html>