Question

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.

Was it helpful?

Solution

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.

Licensed under: CC-BY-SA with attribution
Not affiliated with sharepoint.stackexchange
scroll top