How to Create SharePoint Popups for New Item Forms


By using modal popups instead of linking directly to the new item forms for a list, you can save the end user the frustration of having to go back and figure out where they were before they decided to click the link to add the item to the list, while also giving a much more polished look to the site in general.

Adding the button element

While you can apply this method to direct links, it looks nicer if you create a button for the user to interact with, so put some place holder text where you want the button to go and then open the site in SharePoint Designer 2013.

Look for the placehoder text you created and replace it with the following:

<input id="btnSubmitIssue" type="button" value="Submit an Issue" />

Adding the JavaScript

The javascript is where all the action really happens here, and you will need to add an HTML Script Editor web part in order to get this working. It doesn’t matter where on the page it goes, just that it is there. Put this code inside of the script editor web part:

<script type="text/javascript">
    // Replace ‘btnSubmitIssue’ with whatever the ‘id’ of the button you placed is
    var btnSubmitIssue = document.getElementById('btnSubmitIssue');

    function submitIssue() {
            // Replace ‘ESB%20Process%Issue’ with the URL encoded name of any list
            url:   '../Lists/ESB%20Process%20Issue/NewForm.aspx',
            // Replace ‘Submit an Issue’ with whatever you want the title of the popup to be
            title: 'Submit an Issue'
        return false;
    btnSubmitIssue.onclick = submitIssue;

That code is pretty simple, and all you will need to do is replace the items noted in the comments with the specific elements that you actually want on the popup. It is possible to place other items in the url field, but this tutorial is focused specifically on new item forms for lists. Feel free to experiment with the limits of what SharePoint can place inside of there.