locked
SP List form - additional save button RRS feed

  • Question

  • I have added a 2nd save button to a custom list's edit form by adding any additional <td> tag as shown in the code below. This was done in SharePoint Designer by copying the <td> tag containing the original submit button, then changing its id and it's text:

    <tr>
      <td width="99%" class="ms-toolbar" nowrap="nowrap"><IMG SRC="/_layouts/15/images/blank.gif" width="1" height="18"/></td>
      <td class="ms-toolbar" nowrap="nowrap">
    	<SharePoint:SaveButton runat="server" ControlMode="Edit" id="savebutton101" Text="Confirm"/>
      </td>
      <td class="ms-toolbar" nowrap="nowrap">
    	 <SharePoint:SaveButton runat="server" ControlMode="Edit" id="savebutton1"/>
      </td>
      <td class="ms-separator">&#160;</td>
      <td class="ms-toolbar" nowrap="nowrap" align="right">
    	<SharePoint:GoBackButton runat="server" ControlMode="Edit" id="gobackbutton1"/>
      </td>
    </tr>
    

    I now have 3 buttons, and my newly created button (Confirm) has an onClick event receiver attached to it (by linking a js script in a CEWP).

    The problem is, this Confirm button doesn't save the SharePoint list item, and I have no idea how to do this - (I was hoping I could see what the 'normal' save button is doing and copy that across tot he 'Confirm' button.

    Could somebody please tell me how I can get my Confirm button to save the SharePoint list item in the same way the Save button does?

    Thursday, January 11, 2018 4:08 PM

Answers

All replies

  • Hi,

    You should call the save method to post the information to the SharePoint list:

    <input style="margin:0" id="customSave" type="button" value="custom Save" name="btnSave" onclick="if (!ExecuteThisFunctionBeforeSavingAndRedirecting()) return false; {ddwrt:GenFireServerEvent('__commit;__redirect={webAbsoluteUrl/Lists/ListName/NewForm.aspx?isCustomSaved=Yes}')}" />  
    

    http://www.c-sharpcorner.com/blogs/create-custom-save-and-redirect-button-on-a-sharepoint-form

    http://www.enjoysharepoint.com/Articles/Details/sharepoint-2013-create-custom-save-and-redirect-button-on-a-sharepoint-form-22132.aspx


    Regards,
    Marutha
    Please click the "Mark as Answer" button if a post solves your problem or click "Vote As helpful" button if it was helpful!
    Explore the SharePoint

    • Marked as answer by PetyrBaelish Friday, January 12, 2018 1:37 PM
    Thursday, January 11, 2018 4:34 PM
  • Hi,

    Here is my test sample followed by your solution, you could try the solution shared by Maruthachalam also.

    Custom list form by SharePoint designer.


    Insert below code to script editor webpart in custom list form.

     <script type="text/javascript" src="https://code.jquery.com/jquery-1.12.4.js"></script>
        <script type="text/javascript">
            ExecuteOrDelayUntilScriptLoaded(init, "sp.js");
            function init() {
                var _OOBClick = $('input[value = "Confirm"]')[0].onclick;
                if (_OOBClick) {
                    $('input[value = "Confirm"]').removeAttr("onclick");
                    $('input[value = "Confirm"]').click(function (event) {
                        if (confirm('do something')) {
                            _OOBClick();
                        } else {
                            alert('canceled');
                        }
                    })
                }
            }
        </script>


    Best Regards,

    Lee


    Please remember to mark the replies as answers if they help.
    If you have feedback for TechNet Subscriber Support, contact tnmff@microsoft.com

    Friday, January 12, 2018 7:46 AM