Advanced Search Web Part – using drop down lists instead of plain text boxes

I’ve wanted to use dropdown lists in the advanced search property restrictions for a long time, so i created a web part to allow it (SearchExtension web part). It can be found on codeplex:

How it works:

  • On page load the web part locates the advanced search box and passes its client ID to the client-side in javascript
  • On the DOM ready event, javascript uses the clientID to find the proprety restriction dropdown lists, and adds events to them
  • The events are triggered when the selected property changes, and cause the plain text box to be hidden, and a drop down list created and displayed in its place. The dropdowns created will pass their selected value to the orginal (hidden) text box which used to be there
  • Dropdown list values are populated using callbacks from SharePoint lists or can be defined static (defined in the configuration XML of the SearchExtension web part)
  • Two properties can be linked as parent/child – eg for “Category” / “Sub-category” scenarios
  • The javascript is cross-browser (IE6+ & recent versions of other browsers: FireFox, Chrome, Safari – earlier versions untested)

Please see the codeplex site for more information.