Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

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.

share|improve this question
1  
Are you sure you need to POST? Search works fine when you do a GET with the search query in the query string. –  GavinB Mar 5 '12 at 19:59
    
Thanks, GavinB. I'm good with either method, as long as it works :) –  Alex C Mar 6 '12 at 6:02

1 Answer 1

up vote 0 down vote accepted

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.

share|improve this answer

Your Answer

 
discard

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.