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

155
Vistas
Set different url in the action(form) based on input

I want the action of the form to have different urls based on the input that is passed to it, the problem is that passing the correct urls to the action does not work as it should.

Next I will put some images to be more descriptive

This is the form

<div id="search">
    <form id="formID" action="javascript:;" onsubmit="chgAction()" autocomplete="off">
        <input id="inputID" type="text" placeholder="Search.." autofocus="autofocus">
    </form>
</div>

Here I take the value of the input and I nest it to reddit and in the end I pass it as action and it doesn't work

var text = document.getElementById("inputID").value
document.getElementById("formID").action = "https://www.reddit.com/search/?q=" + text;

The result is this enter image description here

The url is like 'bugged', but if i use POST in method (form) I get the correct url but say this.

enter image description here

But If i click on the url then enter if it works. enter image description here

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

0

I believe it is because the GET request is sending out the request before you can obtain the value of the input. I would suggest using e.preventDefault() instead, then create your URL based on the input, then send a fetch() request.

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