Hi and thanks for the help in advance!
I'm currently working in SharePoint 2010. I have a search box that uses an image onclick() event to fire the search. It works great when you click the image icon but doesn't work at all when you click enter once in the text box. Here is the code for the button.
<div style="position:relative; top:-3px; ">
<label for="Search"><b>SEARCH</b>
</label>
<label for="Content">
<input id="Content" type="radio" name="radiou" value="URL" checked="checked" style="margin-bottom:5px" />Content</label>
<label for="Employees">
<input id="Employee" type="radio" name="radiou" value="URL" style="margin-bottom:5px" />Employee</label>
<input id="search_txt" title="Enter search words" type="text" name="k" maxlength="80" size="25" />
<img src="/Style Library/Images/Search_button.png" onclick="submitSearch()" alt="Search Button" style="margin:0px; position:relative; top:7px; width:30px;"></img>
</div>
Here is the javascript that activates the code on button click. I'd like this to also be fired after typing a term and clicking the Enter key.
< script type = "text/javascript"
language = "JavaScript" >
// <![CDATA[
function submitSearch() {
var radiovals = document.getElementsByName("radiou");
var hostnameforsearch = window.location.hostname;
if (radiovals[0].checked) {
queryVal = $('#search_txt').val();
var searchUrl = 'http://' + hostnameforsearch + '/search/results.aspx?k=' + queryVal + '&u=' + hostnameforsearch + '&cs=This Site';
window.location = searchUrl;
return false;
} else {
queryVal = $('#search_txt').val();
window.open('http://search.URL.com/Pages/PeopleResults.aspx?k=' + queryVal);
};
}; // ]]>
< /script>
Thanks for all the help! Ken