- Do everything from the first post
- Add a link to jQuery somewhere on the page.
- Create a custom list called ‘Suggestions’. It just needs to have the default title field. Create at least one item in the list and in the title enter several comma separated words.
- Add the code below to the page.
The code above get the items from the Suggestions list, seperates them with commas and puts them in a hidden div with an ID of data. Now we just need to edit the searchfield script to read in the information from our hidden div. To do this edit searchfield.js line 26 to call the GetItemsFromSP function and set the suggestionText variable to be equal to the contents of our hidden div. Here is the code.
/**/*/*/*/**/ GetItemsFromSP(); var suggestionText = $(“#data”).html();
Test the page and make sure it works by typing the first few letters of one of the words in you list item.
This is very similar to Jan Tielens’ SharePoint Search-as-You-Type with jQuery solution but I wanted the search box to still be usable even if there are no suggestions. In Jan’s solution the ‘search box’ does not actually do anything when the magnifying glass is clicked. There are likely better ways to do this and if you know of one please post a comment.
- Adding Suggestions to the Sharepoint search box
- Simple Search Box with Radio Buttons
- Image Slideshow with captions