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

143
Vistas
Passing a single variable to an href in html

          <div class="d-flex align-items-center">
                      <div class="container-fluid" style="float: right;">
                        <form class="d-flex">
                          <input type="text" placeholder="Search" aria-label="Search" style="width: 400px;" id="searchTerm" name="searchTerm" ></input>
                          <script>
                            var inputVal = document.getElementById("searchTerm").value;
                          </script>
                          <a href="/articles/search" class="btn btn-success" onclick="location.href=this.href+'?term='+inputVal;" style="width: 100px;">Search</a>
                
              </form>
            </div>
          </div>

I am trying to pass the value from the input to a new page and then retrieve that variable on the next page. I am not sure that I am passing it correctly and am not sure how to retrieve it once it is sent to the next page.

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

0

You can use the "change" event listener:

let inputElement = document.querySelector("#searchTerm");

inputElement.addEventListener("change", ()=>{
    let inputVal = document.getElementById("searchTerm").value;
    let anchorElement = document.querySelector(".d-flex > a");
    anchorElement.href = `/articles/search/${inputVal}`;
});
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