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

162
Vistas
Get text if I select some value from drop list HTML app script

I have this code to get some text if I select a value from the drop list:

<!DOCTYPE html>
<html>
<body>

<div id="addOrderPrompt">
    <center>
    <form> 
      <div id="containerT0"><label for="example">Drop List:</label>
        <select name="exchange" id="exchange">
          <option value="first" rel="firstTarget">First</option>
          <option value="second" rel="secondTarget">Second</option>
        </select>
       </div>
        <a href="https://www.google.com" target="_blank" class="firstTarget">Google</a>
        <a href="https://www.facebook.com" target="_blank"class="secondTarget">Facebook</a>
      </select>
    </form>
    </center> 
</div>

</body>
</html>

I want to hide links I show it if I select some value from the droplist. For example, if I select from the drop list 'First' I want to see just a google link, and if I select 'second' just see the Facebook link.

This is my result:

enter image description here

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

You can get the selected option from JavaScript using the onchange event and handle the visibility of links using the display property. Here's an example:

function handleChange() {
  var userValueElement = document.getElementById("exchange");
  var userValue = userValueElement.options[userValueElement.selectedIndex].text;
  if (userValue == "First") {
    document.getElementById('google').style.display = 'inline';
    document.getElementById('facebook').style.display = 'none';
  } else if (userValue == "Second") {
    document.getElementById('google').style.display = 'none';
    document.getElementById('facebook').style.display = 'inline';
  }
}
<!DOCTYPE html>
<html>

<body>

  <div id="addOrderPrompt">
    <center>
      <form>
        <div id="containerT0"><label for="example">Drop List:</label>
          <select name="exchange" id="exchange" onchange="handleChange()">
            <option value="first" rel="firstTarget">First</option>
            <option value="second" rel="secondTarget">Second</option>

          </select>
        </div>

        <a id="google" href="https://www.google.com" target="_blank" class="firstTarget">Google</a>
        <a id="facebook" href="https://www.facebook.com" target="_blank" class="secondTarget" style="display: none">Facebook</a>
        </select>
      </form>
    </center>
  </div>

</body>

</html>

about 4 years ago · Juan Pablo Isaza Denunciar
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