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

74
Vistas
As a selection the option present in the drop-down menu to the value we get from the parameter we pass in the URL

I have a URL with a parameter, as shown below.

http://example.html?name=Sport

To retrieve the parameter I use the following lines of code:

let url_string = window.location.href;
let url2 = new URL(url_string);
let name_url = url2.searchParams.get("name");

And so far there are no problems.

I want this parameter present in the url to be used as an option for the select, therefore already pre-set to the value that corresponds to the parameter we pass in the URL (in our case on Sport).

I tried to search on the internet but the examples I found are shown in jQuery but I only need it in Javascript.

Can anyone help me to do this?

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

0

Assign name_url to the .value property of the select.

let url_string = window.location.href;
let url2 = new URL(url_string);
let name_url = url2.searchParams.get("name");
document.getElementById("your-select").value = name_url;

Replace your-select with the ID of the <select> that you want to preset.

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