Save Button Options

Forums Dynamic Forms for SharePoint Save Button Options

This topic contains 8 replies, has 3 voices, and was last updated by  CinderGirl 2 months ago.

  • Author
    Posts
  • #22214

    CinderGirl
    Participant

    Hey there! Couple of questions for the Save button:
    1. Is there a way to change the text so it reads ‘Submit’?
    2. How can I change the redirect to go to a specific site page?

    Found some old posts from 2015 but then saw the options under Misc and was wondering if those were used to solve for this? Couldn’t find any info on “Save and redirect” in the User manual?

    TIA!!

  • #22218

    Keith Hudson
    Participant

    1. Here’s some code I have used in the past to change the text on the Save button:

    function changeSaveButton(currLabel,newLabel){
    var inputcontrols = $(‘input’);
    alert(inputcontrols.length);
    for(i = 0; i<inputcontrols.length; i++)
    {
    if(inputcontrols[i].type == “button” && inputcontrols[i].value == currLabel)
    inputcontrols[i].value = newLabel;
    }
    }

    2. Redirecting the user to a specific page after clicking Save can be done with basic SharePoint functionality. Simply include the url of the page you want the user directed to after they save OR cancel the New form by including it as the Source querystring parameter on the link they click to open the new form on your list.

    For instance, if your list is named MyList, and you want the user to go to a page called ThankYou.aspx located in your Pages library after they save or cancel, give them this link to click to start a new item: http://myserver/sites/MySite/Lists/MyList/NewForm.aspx?Source=/sites/MySite/Pages/ThankYou.aspx.

  • #22224

    CinderGirl
    Participant

    Thanks again! Will give this a try shortly 🙂

  • #22226

    CinderGirl
    Participant

    Hey Keith,

    So when I use the function, errors pop up. Here’s the changes I made. Can you help me figure out what I did wrong?

    Errors:
    1. DFFS: There is an error in the custom JS textarea, could not complete the operation due to error 80020101.
    2. DFFS Confi error in “Run these functions/trigger these rules

    I’m just calling function changeSaveButton.

    function changeSaveButton(Save,Submit){

    var inputcontrols = $(‘input’);
    alert(inputcontrols.length);
    for(i = 0; i<inputcontrols.length; i++)
    {
    if(inputcontrols[i].type == “button” && inputcontrols[i].value == currLabel)
    inputcontrols[i].value = newLabel;
    }
    }

  • #22245

    Alexander Bautz
    Keymaster

    Hi,
    I guess these error are caused by wrong type of quotes in the code snippet (caused by copy-paste from the comment). Try retyping all quotes in the snippet.

    Redirecting to another page can also be done using this built in DFFS function:

    spjs.dffs.redirect("TheRedirectURL",false);

    Depending on the SharePoint version this might not work, but if you are able to control the URL you can use the Source parameter like Keith described.

    You can also target the save button directly by its id (using a selector where id ends with):

    jQuery("input[id$='_diidIOSaveItem']").val("New save btn label");

    Alexander

  • #22293

    CinderGirl
    Participant

    Sigh, yep. Again, so obvious looking at it now. The issue was the quotes. And I’m usually good with modifying those. Thanks for pointing that out! In the end I used Alex’s version because after fixing the quotes, it was still giving me an error, stating the currLabel value wasn’t set, so I must have change the wrong value.

    And the redirect worked great! I’m using Keith’s version for a link on a site page and Alex, using yours on the form pages.

    Thanks!!

  • #22310

    CinderGirl
    Participant

    Alexander,
    Hey Alexander,
    Is there a version of this for the Edit button? Scoured the forums and found a version for the Cancel button but not for Edit on the dispform.

    Save: jQuery(“input[id$=’_diidIOSaveItem’]”).val(“Submit This”);
    Cancel: jQuery(“input[id$=’_diidIOGoBack’]”).val(“Cancel This”);

    Gave EditItem a shot but that was a no-go lol.

    TIA!!

  • #22320

    Alexander Bautz
    Keymaster

    Hi,
    Add this to your Custom JS in DispForm:

    jQuery("#Ribbon\\.ListForm\\.Display\\.Manage\\.EditItem-Large span:last").html("New<br>Label");

    Alexander

  • #22388

    CinderGirl
    Participant

    Works perfectly! Thank you!

You must be logged in to reply to this topic.