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

169
Vistas
Multiple form filter GET paramaters

I have 2 forms GET to filter data, when I submit the first form I have this url test.com?form1_filter['year']=2022

It works, but now if I want to submit the other form I would like to have test.com?form2_filter['users']&form1_filter['year']=2022

The problem is when I submit a form, the parameters of the second form were remove

How can I keep all parameters in url ? I tried in javascript with the event submit when it still remove my parameters.

<form id="form1" method="get">
<div>
    <label for="name">Enter your name: </label>
    <input type="text" name="name" id="name" required>
</div>
<div>
    <label for="email">Enter your email: </label>
    <input type="email" name="email" id="email" required>
</div>
<div>
    <input type="submit" value="Filter">
</div>
</form>

<form id="form2" method="get">
<select name="users" id="user-select">
    <option value="1">Dad</option>
    <option value="2">Mom</option>
</select>
<div>
    <input type="submit" value="Filter">
</div>
</form>

It's 2 form on the same page

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

0

The form needs to have inputs for all the data you want to appear in the query string.

If you want to copy existing values without displaying a UI control for them, add them as hidden inputs.

<input type="hidden" name="form1_filter['year']" value="2022">
about 4 years ago · Juan Pablo Isaza Denunciar

0

When you have two form on page that was loaded with URL query string, the newly sent form replaces all the parameters.

The solution is simple: Add hidden fields to the form dynamically (using server-side code) that will add the parameters back to the url.

<input type=hidden name=field-name value=field-value>

You can also do it using JS (not recommended).

Probably better solution is to redirect all requests to other URL that does not use the query string parameters. When query string is added to this URL, also redirect it (to URL that combines both). Example:

/foo?field1=bar
  → /foo/field1=bar

/foo/field1=bar?field2=baz
  → /foo/field1=bar,field2=baz

The only downside of this approach is that it is more complex on the server side.

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