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

151
Visualizações
Using JavaScript Radio Buttons to Change ALL Images Rather Than a Single Image

I have an HTML script set up right now that utilizes radio buttons to change a single image from a weighted-mean map to its unweighted counterpart. In other words, the HTML form is tied to an individual image and calls on a JavaScript function to change the image (there are two radio buttons under each image, one for the weighted-mean image and the other for the unweighted image).

Here are my JavaScript functions followed by the HTML code:

function preLoad() {
   
    a1 = new Image; a1.src = 'NorthAmerica_Weighted.png' 
    a2 = new Image; a2.src = 'NorthAmerica_Unweighted.png'

    b1 = new Image; b1.src = 'Europe_Weighted.png'
    b2 = new Image; b2.src = 'Europe_Unweighted.png'
}

function im(image) {
     document.getElementById(image[0]).src = eval(image + ".src")
}
<body onLoad="preLoad()">
<center>

<tr>
           <th>
            <img id="a" src="NorthAmerica_Weighted.png" width="450" height="400" alt="">
            <form autocomplete="off">
          <input type="radio" name="5" onClick="im('a1');" checked> Weighted
              <input type="radio" name="5" onClick="im('a2');"> Unweighted
        </form>

           <th>
            <img id="b" src="Europe_Weighted.png" width="450" height="400" alt="">
            <form autocomplete="off">
          <input type="radio" name="5" onClick="im('b1');" checked> Weighted
              <input type="radio" name="5" onClick="im('b2');"> Unweighted
            </form>
      </tr>
      </table>
    
</center>
</body>

I want to create a single set of radio buttons at the top of the page (rather than one below each image) that change ALL images at the same time from the weighted images to the unweighted images. So clicking on the "unweighted" radio button should switch the North America image from "NorthAmerica_Weighted.png" to "NorthAmerica_Unweighted.png" and the Europe image from "Europe_Weighted.png" to "Europe_Unweighted.png". I moved the HTML form to the top of the page, but I am unsure how to change the "img" block to get this to work.

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