Redirect Users to Thank You page from NewForm.aspx after form submission
Requirement: Redirect to a page after adding a new item to a list.
Here is my requirement: I have a SharePoint request tracking system. When users create a new entry, what I want is to redirect them to “Thank you! We have received your request. We will get back to you on this soon!”, typical acknowledgment page 🙂
So, to redirect page after form submission in SharePoint, create a custom NewForm.aspx, hide the default “Ok” and “Cancel” buttons, and then insert the below code:
Redirect NewForm, EditForm Submit button:
<input type="button" value="Submit" name="btnSave" onclick="javascript: {ddwrt:GenFireServerEvent('__commit;__redirect={/sites/marketing/SitePages/thankyou.aspx}')}" />
Change SharePoint Cancel button Redirect:
<input name="btnSave" onclick="javascript: {ddwrt:GenFireServerEvent('__redirect={/sites/marketing/SitePages/Home.aspx}')}" type="button" value="Cancel">
Alternate approach: Using Source URL Parameter in SharePoint List Forms
If you want to send users to some other page (Doesn’t matter whether the user press “Ok” or “Cancel”), SharePoint allows us to control OK and Cancel button behavior with the “source” parameter. Here is an example: Â
https://sharepoint.crescent.com/sites/Operations/Lists/Tasks/NewForm.aspx?Source=/sites/operations/SitePages/Home.aspx
There is one issue when using the Source parameter is: you will get Thank you page even when you click on the “Cancel” button. Let’s mitigate that by adding jQuery: It binds a function with the “Cancel” button’s click event. (Edit the NewForm.aspx page and add a CEWP, just below NewForm Fields. Place this script in a text file, upload and point it from a CEWP)
SharePoint: redirect cancel button
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.3/jquery.min.js"></script>
<script type="text/javascript">
$(document).ready(function()
{
$('input[value=Cancel]').click(function() { window.location.replace("https://sharepoint.crescent.com/sites/operations/SitePages/Home.aspx");});
});
</script>
Related Post: SharePoint Survey Redirect to Thank You Page on Finish
hi
Please guide me:
I want in the second approach function is working but data is saving in the list.
Thanks in advance
Hi Can you please help with anonymous users. The &Source= does not work for anonymous users
JavaScript to Check for Required Fields: Name, Phone Number or Mailing Address, and E-Mail Address
Prompts for Missing Required Fields
Once the Required Fields Have been Entered Cookie is Placed on the users computer.
If same user attempts to open page with cookie, user is redirected to a new web page stating the form has been filled out.
Hi,
I have added one HTML button on the Default SharePoint 2010 List Edit form dynamically using Jquery.
Code:1
$(priotr).before(‘<_input id="btnTest" Name="btnTestSubmit" type="button" onclick = "javascript: {ddwrt:GenFireServerEvent('__commit')}" value="Submit Button">
at the time of button click. i get error “Object expected”
Any idea why.
i also tried other option.
Code:2
$(priotr).before(‘<_input id="btnTest" Name="btnTestSubmit" type="button" onclick="javascript: __doPostBack('btnTestSubmit''+ ','+''__commit')" value="Submit Button">
in the second approach function is working but data is not saving in the list.
Thanks in advance
Arvind
Thanx! This artical really helped me ! but one problem is that when me submited data i dont need to go back button (<=)