Skip to main content
King County logo

If you want to offer your users the opportunity to search within only a certain site or section of a site, use this code snippet. The example below would search Solid Waste's media library.

  • Edit "Search within this section" to say whatever you want the button to say.
  • Edit "" to be whatever area you want to limit the search to. 

Step one: Put this in your HTML code where you want the search form to appear.

<form id="search_form" action="//" method="get" accept-charset="UTF-8">

<div style="margin: 0px; padding: 0px; display: inline;">

<input name="utf8" type="hidden" value="✓" />


<label for="query">Enter term(s): </label>

<input name="q" id="query" type="text" />

<input name="commit" type="submit" value="Search within this section" onclick="searchSpecial()" />


Step two: Put this in the custom script field:


function searchSpecial()


var specialsearch = $( "#query" );

specialsearch.val( "site:" + specialsearch.val() );