0

I have a custom HTML form and I need to add a second save button to my form on the top.

So I created my button and can not find the right javascript function that will submit my form. Basically, I just want the SAVE button from the bottom of the form, a second time.

What is the save function then?

I tried but without full success. It seems to submit but dont close the form after:

<script>
//Save function
    $('.saveForm').click(function() { 
        $("input[value$='Save']").attr('value', "Submit");
    });
//Set up button
    $( ".saveForm" ).button();
</script>

If I use the debugger from Internet Explorer, I can see the following code for the SAVE button. Could it be reused somehow?

onclick="
if (!PreSaveItem()) return false;
if (SPClientForms.ClientFormManager.SubmitClientForm('WPQ2')) return false;
WebForm_DoPostBackWithOptions(new WebForm_PostBackOptions(&quot;ctl00$ctl39$g_72f104b2_2e10_4b81_9692_a4c10eacd37f$ctl00$toolBarTbl$RightRptControls$ctl00$ctl00$diidIOSaveItem&quot;, &quot;&quot;, true, &quot;&quot;, &quot;&quot;, false, true))"
0

I played a bit again with the code and it seems to works now

//Save function
    $('.saveForm').click(function() { 
        if (!PreSaveItem()) return false;
        if (SPClientForms.ClientFormManager.SubmitClientForm('WPQ2')) return false;
        WebForm_DoPostBackWithOptions(new WebForm_PostBackOptions('ctl00$ctl39$g_72f104b2_2e10_4b81_9692_a4c10eacd37f$ctl00$toolBarTbl$RightRptControls$ctl00$ctl00$diidIOSaveItem', '', true, '', '', false, true))
    });
//button
    $( ".saveForm" ).button();
-2

Yes you can use that by removing the existing click event for save button and add your custom click event please find below sample which i did for my approve button I have added additional confirmation on click event.

$(document).ready(function() {

     var approvebutton = $('[value="Approved"]');

            approvebutton.removeAttr("onclick");
            approvebutton.click(function() {
            return confirm('are you sure you want to approve?');if (!PreSaveItem()) return false;
    if (SPClientForms.ClientFormManager.SubmitClientForm('WPQ2')) return false;WebForm_DoPostBackWithOptions(new WebForm_PostBackOptions('ctl00$ctl49$g_ee2ab7f9_8310_408f_a556_5718bc7de59b$ctl00$toolBarTbl$RightRptControls$ctl00$ctl00$diidIOSaveItem', '', true, '', '', false, true)

    });
  • Nothing after the return confirm(); will execute... – wjervis Mar 1 '17 at 12:41
  • You don't keep return confirm('are you sure you want to approve?'); in your case only keep this one in click event if (!PreSaveItem()) return false; if (SPClientForms.ClientFormManager.SubmitClientForm('WPQ2')) return false;WebForm_DoPostBackWithOptions(new WebForm_PostBackOptions('ctl00$ctl49$g_ee2ab7f9_8310_408f_a556_5718bc7de59b$ctl00$toolBarTbl$RightRptControls$ctl00$ctl00$diidIOSaveItem', '', true, '', '', false, true) – Suresh Bolineni Mar 2 '17 at 4:47
  • 2
    I'm not here for help, I was just reviewing the question. I happened to notice your answer contained code that will never execute, because it's behind a return. Why have the code if it'll never execute? – wjervis Mar 2 '17 at 12:30
  • Who are you man? I am just giving hit to Romain so that he will analyze how to keep the script. he already said that he identified the script and it is working onclick=" if (!PreSaveItem()) return false; if (SPClientForms.ClientFormManager.SubmitClientForm('WPQ2')) return false; WebForm_DoPostBackWithOptions(new WebForm_PostBackOptions('ctl00$ctl39$g_72f104b2_2e10_4b81_9692_a4c10eacd37f$ctl00$toolBarTbl$RightRptControls$ctl00$ctl00$diidIOSaveItem', '', true, '', '', false, true))" – Suresh Bolineni Mar 3 '17 at 10:05

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.