Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

150
Visualizações
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 Respostas
Responde à pergunta

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda