0

I have written following code to popup a new page when my list new form save button is clicked.

$(document).ready(function() {
        $('input[value=Save]').click(function() {
                var Width = 1050;
                var Height = 550;
                var left = (screen.width - Width) / 2;
                var top = (screen.height - Height) / 4;
                var myWindow = window.open("someurl");
        });

    });

But my expectations are as follows:

  1. Until I enter values in popup window and submit/close the popup, my parent form should not be submitted.
  2. I should be able to submit the parent list form once I submit/close the popup window(not before that).

I have done some research on internet, but couldn't find a way. Appreciate your help.

1 Answer 1

1

As a workaround, we can redirect the new page on Save button click in list item new form page. The following code for your reference, add the code into script editor web part in new form page.

<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
<script>
$(document).ready(function(){
    var targetURL = 'YOUR URL';
    //For Cancel Button
    $("input[value='Cancel']").attr("onclick","location.href='" + targetURL +"';");  
    //For Save Button
    var saveButton = $("input[value='Save']");
    saveButton.removeAttr("onclick");
    saveButton.click(function() {
        if (!PreSaveItem()) return false;
        if (SPClientForms.ClientFormManager.SubmitClientForm('WPQ2')) return false; 
        var oldActionUrl = $('#aspnetForm').attr('action');
        var oldSource = GetUrlKeyValue("Source", true, oldActionUrl);           
        var newActionUrl = oldActionUrl.replace(oldSource, encodeURIComponent(targetURL));
        var elementName = $(this).attr("name");
        WebForm_DoPostBackWithOptions(new WebForm_PostBackOptions(elementName, "", true, "", newActionUrl, false, true));
    });    
});
</script>

Refer to: How to redirect different page on Save button click on SharePoint Forms using client side script

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.