Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

185
Vistas
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 la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda