I’m trying to pass the ID option attribute to the function swapImage() instead of passing the VALUE attribute.
The code below works fine but I want value to be equal to an ID, not the image URL. I tried changing dropd.value to dropd.id within the function but that gave me an error.
Is it possible to pass the option ID attribute to the function and if so, how? I’m open to using rel=“” insteal of id=“” if necessary.
Thanks
Eric
function swapImage(){
var image = document.getElementById("imageToSwap");
var dropd = document.getElementById("dd");
image.src = dropd.value;
};
If I understand you correctly, you want to obtain the id of the currently selected option in the “dropd” selection box - right? That can be achieved like so:
I wonder if numbers are used for values because they’re way shorter than the long img filenames? I’m lazy myself and hate typing long anythings (so, I wouldn’t have even used such long names for the id’s either).