To simplify the form building for users who know HTML, we decided to use the out of the box HTML Form Web Part. That web part has some limitations. Specifically, you cannot add or embed another <form> tag to the source code. Without the ability to specify the OnSubmit for the form, there has to be another way to indicate the method and action on the submit of the form.
After searching Google, I can upon this CodePlex project: “SharePoint form submit in content editor web part” and subsequent version 2, which handles the parameters much nicer.
There was a small problem with the HTML. SharePoint handles multiple web parts on a page by prepending the field names with “WPQ#”, where # is some number. This is fine until the service you are posting to expects the field names to be a specific name. By modifying the jquery, I update the field names using these lines of code in the file jquery.SharePointFormSubmit.js:
var wpPrefix = arr[‘wpPrefix’];
newName = $(this).attr(‘name’).replace(wpPrefix, "");
The wpPrefix is the prefix of the web part that is set by SharePoint on that particular page. This can be found by viewing the page source of the HTML Form Web Part. In my case, it was “WPQ7.”
The field names are updated on the submit. It is a good idea to view what the form is passing using some HTTP tools. My favorite is FireFox with the Firebug and Live HTTP Headers Add-Ons.
And there you have it.
#1 by Kensley Lewis on January 30, 2013 - 4:06 pm
Thank you for the good post
Just out of curiosity, Is there an OOTB web part that allows you to use a username and password input field with submit button form? We have to relay on the jQuery technique you mentioned on this page for something simple like that?
#2 by Jake on January 31, 2013 - 4:03 pm
Hi Kensley… if you are just adding a simple button, you can do that with the HTML Form Web Part. Here’s a little article about it from MS