I have two differents select tag, but my script change both at the same time!!!! I need each image change with yours respective Select
How can I do that?
Please HELP from Brazil.
Sorry for my bad english.
My Code

<html>
<head>
<script type="text/javascript">
/* URL of folder with images  */
var baseURL_OF_images = "./";
/* array of default image files */
var images =
      [ "bronze.png", "prata.png",
        "gold.png", "platina.png",
        "diamante.png" ]
function switchImage(imgNum){
  var x = parseInt(imgNum);
  var src = baseURL_OF_images
                + ( ( x < 0 ) ? "bronze.png": images[x] );
  document.getElementById("#AvatarImage").src = src;
  document.getElementById("#AvatarImage2").src = src;
  return true;
}
</script>

</head>
<body>
<img id="#AvatarImage" name="#AvatarImage" src="bronze.png" style="widht:200px;height:200px;"/>
<select id="#AvatarImage" onChange="switchImage(this.options[this.selectedIndex].value);">
  <option value="0" selected="-1">Bronze</option>
  <option value="1">Prata</option>
  <option value="2">Ouro</option>
  <option value="3">Platina</option>
  <option value="4">Diamante</option>

</select>

<img id="#AvatarImage2" name="#AvatarImage2" src="bronze.png" style="widht:200px;height:200px;"/>
<select id="#AvatarImage2" onChange="switchImage(this.options[this.selectedIndex].value);">
  <option value="0" selected="-1">Bronze</option>
  <option value="1">Prata</option>
  <option value="2">Ouro</option>
  <option value="3">Platina</option>
  <option value="4">Diamante</option>

</select>

</body>
<html>

Recommended Answers

All 6 Replies

A quick read says line 15 and 16 would indeed set both to the same image.

How would it be?

Your code at lines 15 and 16 in the function switchImage. That's why it be so.

I don't have any experience with JavaScript this code I just copy and paste for my use, i don't have the idea how to change this. If you can, please change the lines with mistakes and paste it for me? Thank so much. So I'm going to read your changes in the code and undertand what I was doing wrong.
Sorry bad english.

Sorry but this is for you to fix. I can't maintain your code. If this is all new, then learn more about coding or hire someone. If I touched your code, you may expect me to fix it again and again.

Instead I point out where the error lines are and you get to fix them.

Yep, he is right see line 15 and 16... ww.w3schools.com/js/ can help you learn more on javascript

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.