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

133
Views
tratando de agregar entrada de formulario a la URL para la solicitud GET

¿Cómo hago para agregar un objeto al final de mi dirección de URL? En este momento, $ año no se agrega a la solicitud GET.

 <input type = "text" id="year"> <input type = "submit" id="btn"> <script > document.getElementById("btn").addEventListener("click", function() { var $year = document.getElementById("year"); request = new XMLHttpRequest(); request.open("GET", "https://mudfoot.doc.stu.mmu.ac.uk/node/api/halloffame?year="+$year, true); request.send(null); } return val; }
about 4 years ago · Juan Pablo Isaza
2 answers
Answer question

0

use value() después de getElementById para obtener el valor de ese elemento seleccionado

 <input type="text" id="year"> <input type="submit" id="btn"> <script> document.getElementById("btn").addEventListener("click", function () { var $year = document.getElementById("year").value; request = new XMLHttpRequest(); const reqUrl = "https://mudfoot.doc.stu.mmu.ac.uk/node/api/halloffame?year=" + $year console.log("reqUrl: ", reqUrl); request.open("GET", reqUrl, true); request.send(null); }) </script>

about 4 years ago · Juan Pablo Isaza Report

0

Intenta usar:

 document.getElementById("btn").addEventListener("click", function() { var $year = document.getElementById("year").value; request = new XMLHttpRequest(); request.open("GET", "https://mudfoot.doc.stu.mmu.ac.uk/node/api/halloffame?year=" + $year, true); request.send(null); }

Creo que su problema era que no estaba obteniendo el valor de la entrada, solo estaba seleccionando el elemento.

Estabas haciendo: document.getElementById("year") que te da el elemento. Pero debe hacer document.getElementById("year").value que le da el valor del cuadro de texto.

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!