Custom Search Within A Page
- This topic has 1 reply, 2 voices, and was last updated 5 years ago by .
Viewing 1 reply thread
Viewing 1 reply thread
- You must be logged in to reply to this topic.
Home › Forums › General discussion › Custom Search Within A Page
Tagged: classic web part page, search
Here’s some code that creates a custom search in classic web part or wiki page. It will search all web parts only on the current page but regardless if the web parts are batched to show only so many at a time.
Use case: A custom list where I want users to only be able to view or search for entries where their name is in a field, but there are multiple people pickers it could apply to.
Initial setup:
Add this code to the HTML section of the CEWP:
<style unselectable=”on”>
/* hide default search bar */
#DeltaPlaceHolderSearchArea
{display: none;}
</style>
Manager:
<script type="text/javascript">
function RedirectUrl()
{
var mgr = document.getElementById("MgrSearch").value;
if(mgr != null)
{
window.location.href="?FilterName=Manager&FilterMultiValue=*"+mgr+"*";
/* Change Manager to your FIN */
}
return false;
}
</script>
<input type="text" style="width: 100px" id="MgrSearch" onkeydown="if (event.keyCode == 13) {return RedirectUrl();; return false;}"/>
<input type="button" style="min-width: 45px; padding: 3px; margin: 1 0 0px" id="MgrSearch" value="Search" onclick="return RedirectUrl();" />
Thanks for sharing this tip!
Alexander