Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

50
Views
Usar selección desplegable en URL

Estoy siguiendo la respuesta aquí para usar la selección de un menú desplegable en una URL. Estoy usando asp.net core, usando:

 asp-page="/Page" asp-page-handler="Action"

Para hacer la redirección

La secuencia de comandos a continuación (del enlace anterior) funciona muy bien, excepto si selecciona un elemento del menú desplegable y luego selecciona uno diferente (y así sucesivamente), agrega ambos a la URL.

 <script> $("[name=selectedAnalyst]").on("change", function () { var analystId = $(this).val(); var accept = $(this).closest('td').next().find("a")[0]; var oldUrl = accept.href; var newUrl = oldUrl + "&analystid=" + analystId; $(accept).attr("href", newUrl); })

Intenté borrar el parámetro en cuestión (usando params.delete) pero no funciona:

 <script> $("[name=selectedAnalyst]").on("change", function () { var analystId = $(this).val(); var accept = $(this).closest('td').next().find("a")[0]; var oldUrl = accept.href; let params = new URLSearchParams(oldUrl.search); params.delete('analystid') var newUrl = oldUrl + "&analystid=" + analystId; $(accept).attr("href", newUrl); })

¿Hay alguna manera de hacer que el script anterior funcione como imagino, o una mejor manera de hacerlo?

Gracias

about 4 years ago · Juan Pablo Isaza
2 answers
Answer question

0

parece que

 let params = new URLSearchParams(oldUrl.search); params.delete('analystid')

no funciona probé con los códigos y podría funcionar

 <script> $("[name=selectedAnalyst]").on("change", function () { var analystId = $(this).val(); var accept = $(this).closest('td').next().find("a")[0]; var oldUrl = accept.href; var a = oldUrl.indexOf("analystid"); console.log(a); if (a == -1) { var newUrl = oldUrl + "&analystid=" + analystId; } else { var newUrl= oldUrl.substring(0, oldUrl.length - 1) + analystId; } console.log(newUrl); console.log(oldUrl); $(accept).attr("href", newUrl); }) </script>
about 4 years ago · Juan Pablo Isaza Report

0

Sobre la base de lo que Ruikai Feng publicó, creo que esto está funcionando:

 $("[name=selectedAnalyst]").on("change", function () { var analystId = $(this).val(); var accept = $(this).closest('td').next().find("a")[0]; var oldUrl = accept.href; var a = oldUrl.indexOf("analystId "); if (a == -1) { var newUrl = oldUrl + "&analystId =" + analystId ; } else { var newUrl = oldUrl.substring(0, a - 1) + "&analystId =" + analystId; } $(accept).attr("href", newUrl); })
about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!