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

216
Vistas
How do I set the URL of a hyperlink to a js variable?

I need help with setting urls to JS variables,

<input id="urlbox"><a href="main.htm" target=main id=gourl><button>Go</button></a>
<script>
  var urlgo = document.getElementById('gourl');
  var seturl = document.getElementById('urlbox').value;
  setInterval(function() {
  urlgo.setAttribute('href', seturl);
}, 300);
</script>

It doesn't work in any internet browser I tested it in, how do I get it to work?
The behavior I expected is that every 0.3 seconds, the url of the go button is set to the value of the text box, but nothing happens when i use it, does anyone know how to make it work?
If it helps, I don't get an error, but the url just gets set to blank no matter what I enter

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

0

Place the

var urlgo = document.getElementById('gourl');
var seturl = document.getElementById('urlbox').value;

inside the the setInterval.

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