1

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.

2
  • 1
    Are you sure you need to POST? Search works fine when you do a GET with the search query in the query string. Commented Mar 5, 2012 at 19:59
  • Thanks, GavinB. I'm good with either method, as long as it works :) Commented Mar 6, 2012 at 6:02

1 Answer 1

0

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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.