We need to post to a search web application and have it display the results in a new window. Can the SharePoint 2010 HTML Form Web Part do this? Any examples? Thanks.
-
1Are you sure you need to POST? Search works fine when you do a GET with the search query in the query string.GavinB– GavinB2012-03-05 19:59:47 +00:00Commented Mar 5, 2012 at 19:59
-
Thanks, GavinB. I'm good with either method, as long as it works :)Alex C– Alex C2012-03-06 06:02:13 +00:00Commented Mar 6, 2012 at 6:02
1 Answer
This does the job: http://code.google.com/p/jquerysharepointform/ It even lets you define whether to pop the form up in a new window or to do a POST or GET. You just have to ensure jQuery is loaded, then call the function:
<script type="text/javascript" src="/SiteAssets/js/jquery.SharePointFormSubmit.js"></script>
<div id="divIdForm">
<input id="all" width="29" size="29" autocomplete="off" name="all">
<button id="idButton" type="button" onclick = "jQuery().SharePointFormSubmit(
{
'element':'#divIdForm',
'frmMethod':'post',
'frmAction': 'http://myserver/search.aspx',
'frmTarget':'_blank'
})">Search
</button>
<script>
$('#all').bind('keypress',function(e){
if(e.which == 13){
jQuery().SharePointFormSubmit(
{
'element':'#divIdForm',
'frmMethod':'post',
'frmAction': 'http://myserver/search.aspx',
'frmTarget':'_blank'
});
}
});
</script>
</div>
I go a step further and also call the submit if the user hits enter in the input field. Put the whole thing in a content editor web part and you're off and running. The SharePointFormSubmit function replaces the DIV wrapper with a form and submits the information.
Hope this helps others.