This code enables people search without requiring the full name, e.g. search for 'a' will return all names begining with A. To set-up, add a Content Editor web part to the page and insert the code using the Source button. You will need to modify URLs to match your environment for the web part to work. It can also be modified to add other properties, e.g. a dropdown list of departments. It does include script, use in a production environment at your own risk!
===============================
<script language="javascript">
//function to handle enter on keyboard
function txtWildPeopleFinder_KeyDown(e)
{
if (e.keyCode == 13 || e.keyCode==10)
{
e.returnValue=false;
DoWildPeopleSearch();
return false;
}
else
return true;
}
//escape apostrophes in search strings
function escapestr(str)
{
return str.replace("'","%22");
}
//search function
function DoWildPeopleSearch()
{
var firstname = escapestr(document.all["firstname"].value);
var lastname = escapestr(document.all["lastname"].value);
var url;
//search on last name
if(firstname == "")
{
url = "/searchcenter/Pages/peopleresults.aspx?k=LastName%3A" + lastname;
window.location=url;
return;
}
//search on first name
if(lastname == "")
{
url = "/searchcenter/Pages/peopleresults.aspx?k=FirstName%3A" + firstname;
window.location=url;
return;
}
//first and last
url = "/searchcenter/Pages/peopleresults.aspx?k=lastname%3A" + lastname + "%20FirstName%3A" + firstname;
window.location=url;
return;
}
</script>
<table cellpadding="3" cellspacing="0" border="0" width="100%" ID="Table3">
<tr><td width="80" nowrap>First Name:</td>
<td width="100%"><input size="20" maxlength="100" id="firstname" name="firstname" type="text" onkeydown="txtWildPeopleFinder_KeyDown(event)">
</td></tr>
<tr><td width="80" nowrap>Last Name:</td>
<td><input size="20" maxlength="100" id="lastname" name="lastname" type="text" onkeydown="txtWildPeopleFinder_KeyDown(event)">
</td></tr>
<tr><td> </td><td><input type="button" onclick="DoWildPeopleSearch()" value="Search"></td></tr>
</table>
(1 post)
(1 person)


