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

149
Views
Get current value of search input on SharePoint

Would like to get a pure Javascript solution for my situation.

My HTML and JS is as follows. But the HTML can't be manipulated unfortunately as its on SP.

function getCurrentValue() {
  var searchQuery = document.getElementById("SearchBox").children[0].children[0].value;
  console.log(searchQuery);
}
<div id="SearchBox">
  <div id"randomGeneratedId">
    <input type="text" value="Search..." id="anotherRandomGeneratedId"/>
  </div>
</div>
<br/>
<input type="button" value="Run!" onClick="getCurrentValue();">

The JS above works in the snippet here but on my page it returns the default value of the input ie. "Search..."

FYI its running on SharePoint 2013. I should note that I managed to get it to work when getElementId("anotherRandomGeneratedId") but that require writing a custom script for every page.

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

0

Have a try to modify getCurrentValue() to:

function getCurrentValue() {
    var searchQuery = document.querySelector("#SearchBox input").value;
    console.log(searchQuery);
}
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!