SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have developed a Employee Directory and got this javascript for criteria search. But I want to fetch all employees first and then apply criteria. How to set the value of "Fixed Query" of People Search Core Result webpart using javascript when I press the search button without giving any criteria.

 <script language="javascript">

  //function for enter on keyboard and apostrophes in search strings
 function txtWildPeopleFinder_KeyDown(e)
  if (e.keyCode == 13 || e.keyCode==10)
    return false;
    return true;

function escapestr(str)
 return str.replace("'","%22");

//staff search
function DoWildPeopleSearch()
 var firstname = escapestr(document.all["firstname"].value);
 var lastname = escapestr(document.all["lastname"].value);
 var url;
 //search on last name onnly (first name is empty)
 if(firstname == "")
  url = "BankDirectory.aspx?k=LastName%3A" + lastname;
//search on first name only (last name is empty)
if(lastname == "")
  url = "BankDirectory.aspx?k=FirstName%3A" + firstname;
 //search on first and last
 url = "BankDirectory.aspx?k=lastname%3A" + lastname +
 "%20FirstName%3A" + firstname;

 </script><table width="100%" id="StaffSearchTable" border="0" cellspacing="0"          
 cellpadding="4"><tbody><tr><td width="80" nowrap="nowrap">First Name:</td>
 <td width="100%"><input name="firstname" id="firstname"       
 onkeydown="txtWildPeopleFinder_KeyDown(event)" type="text" size="25" maxlength="55"/>       
 <tr><td width="80" nowrap="nowrap">Last Name:</td>  
     <td><input name="lastname" id="lastname"     
      onkeydown="txtWildPeopleFinder_KeyDown(event)" type="text" size="25" 
     maxlength="55"/> </td></tr>

      <td><input onclick="DoWildPeopleSearch()" type="button" value="Search"/></td></tr></tbody></table>   
     <p>Enter all or part of a name<br/>e.g. A will find all names beginning with A</p>
share|improve this question

You would need to edit the CoreSearchResults web part properties and use the "Append Text to Query", see here

This shall automatically trigger a query and still allow you to add your own Keywords.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.