Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

188
Visualizações
Display image based on user selection in two-level cascading dropdown javascript

So, I have two cascading dropdowns, both displaying different images based on user selection. But now I need to restrict the number of images in the second dropdown based on the first dropdown value.

This is an example of how I did that with fonts: https://jsfiddle.net/gjq8ov1h/

But now, I want to do this with images, but I don't even know where to begin.

fyi, I have the first set of images in order like pic1.jpg, pic2.jpg, but the second set is numbered based on its dimensions. i can change rename them with num1, num2, etc. if needed.

I used these both functions to get the images:

var imageList = Array();

for (var i = 1; i <= 8; i++) {

imageList[i] = new Image();

imageList[i].src = "Images/image"+i+".jpg";

}

function switchImage() {

var selectedImage = document.myForm.switch.options[document.myForm.switch.selectedIndex].value;

document.myImage.src = imageList[selectedImage].src;

}

And this for the second one:

function swapImage(){

var image = document.getElementById("imageToSwap");

var dropd = document.getElementById("dlist");

image.src = dropd.value;    
}

I really can't seem to figure it out. Would appreciate any help!

about 4 years ago · Juan Pablo Isaza
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda