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

99
Views
Search form input - Search "as you type" with HTML/Javascript

I have following search form in an HTML page on website built with Django:

<form method="get">
<input class="form-control" type="text" name="q" id="id_q" placeholder="Search...">
</form>

I would like it to perform a search while typing (not having to press enter). I know we could use onchange or onkeyup, but I don't seem to be able to make it work.

The javascript at the bottom of the page is as follows:

<script type="text/javascript">
document.getElementById("id_q").value = "{{query}}"
</script>

Edit: I saw that my search works without the Javascript part above, but I still need to press on Enter. What would be a simple script to launch the search "as you type" without pressing Enter?

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

0

once you onchange you can get your current values and send a API request or anything you want to do something like below-

window.addEventListener('load', () => {
  const input = document.getElementById("id_q");
  input.addEventListener('change', (e) => {
    let currentVal=e.target.value;
    // do anything with this value
  })
})

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!