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

141
Views
Passing a single variable to an href in html

          <div class="d-flex align-items-center">
                      <div class="container-fluid" style="float: right;">
                        <form class="d-flex">
                          <input type="text" placeholder="Search" aria-label="Search" style="width: 400px;" id="searchTerm" name="searchTerm" ></input>
                          <script>
                            var inputVal = document.getElementById("searchTerm").value;
                          </script>
                          <a href="/articles/search" class="btn btn-success" onclick="location.href=this.href+'?term='+inputVal;" style="width: 100px;">Search</a>
                
              </form>
            </div>
          </div>

I am trying to pass the value from the input to a new page and then retrieve that variable on the next page. I am not sure that I am passing it correctly and am not sure how to retrieve it once it is sent to the next page.

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

0

You can use the "change" event listener:

let inputElement = document.querySelector("#searchTerm");

inputElement.addEventListener("change", ()=>{
    let inputVal = document.getElementById("searchTerm").value;
    let anchorElement = document.querySelector(".d-flex > a");
    anchorElement.href = `/articles/search/${inputVal}`;
});
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!