SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Any idea why the PreSaveAction is not firing. I am trying to take the user to a thankyou page when they complete a survey. I added this js thru SP Designer to NewForm.aspx.

<script type="text/javascript" src="'/_layouts/jQuery/jquery-1.6.min.js"> </script>
<script type="text/javascript">
// old handler:
var buttonID = document.getElementById("ctl00_m_g_f46a290b_d993_4347_a2da_868aff18de82_ctl00_toolBarTbltop_RightRptControls_ctl01_ctl00_diidIOSaveItem");
var oldHandler = function() {
if (!PreSaveItem()) return false;
WebForm_DoPostBackWithOptions(new WebForm_PostBackOptions("ctl00_m_g_f46a290b_d993_4347_a2da_868aff18de82_ctl00_toolBarTbltop_RightRptControls_ctl01_ctl00_diidIOSaveItem", "", true, "", "", false, true));
// remove old and add new handler:
var newHandler = function() {
if (!PreSaveItem()) return false;

<input type="button" value="Finish" name="Submit" onclick="if (!PreSaveItem()) return false;{ddwrt:GenFireServerEvent('__commit;__redirect={/thankyou.aspx}');}" />

//WebForm_DoPostBackWithOptions(new WebForm_PostBackOptions("ctl00_m_g_f46a290b_d993_4347_a2da_868aff18de82_ctl00_toolBarTbltop_RightRptControls_ctl01_ctl00_diidIOSaveItem", "", true, "", "", false, true));
return true;
$("#ctl00_m_g_f46a290b_d993_4347_a2da_868aff18de82_ctl00_toolBarTbltop_RightRptControls_ctl01_ctl00_diidIOSaveItem").unbind("click", oldHandler).click(newHandler);
share|improve this question
javascript: {ddwrt:GenFireServerEvent('__commit;__redirect={../../Pages/SurveyWirelessThankYou.aspx}')}

I tried this steps from this link ( and it seems to work. This steps put the above java-script code on the button (click event)

  1. Open survey in SPD, in the page to view and manage setting for the list, click New button on Forms section;
  2. Enter the filename and select "New item form" as the selected type of form. Check "Set as default form for the selected type". Choose "survey" as the content type
  3. Click "OK" and a new form is created.
  4. Open the custom form, delete the default “Finish” button.
  5. Select “Insert” menu at the top of the page>select “SharePoint” from the ribbon>select “Form Action Button” from the SharePoint controls.
  6. In the Form Actions, select the two actions “Commit” and “Navigate to page”
  7. Select the “Navigate to page” action, click “settings” to set the target page : http://sharepoint/pages/thankyou.aspx
share|improve this answer

The simple solution is to craft a hyperlink to the NewForm page that includes a ?Source querystring parameter to the page you want to end up. The hyperlink could be modified by a jQuery script to append the query string parameter. I have an example of that I will try to dig up as a reference.

Edit: Here's the link to the jQuery I was refering to.

<script type="text/javascript">
$(document).ready(function() {
      var curr_URL = document.location.href;
      appendTo_URL = "?Source=" + curr_URL;
      var link_URL = $(this).attr('href');
                //alert(link_URL + appendTo_URL);
      $(this).attr('href', link_URL + appendTo_URL);
share|improve this answer
new form's url looks like this portal/surveys/Lists/TestSurvey/NewForm.aspx?IsDlg=1 ; my var curr_URL='/pages/ThankYou.aspx'; records is added but redirection is not working. – Nancy o'Donnell Sep 7 '11 at 16:32
I opened the IE developer tool and it's chocking on $(document).ready(function(){ line, stating "object expected" character 1 – Nancy o'Donnell Sep 7 '11 at 17:07
Do I need to add a reference to jQuery? or it's a normal javascript? – Nancy o'Donnell Sep 7 '11 at 17:10
It's jQuery, I believe it was from the 1.3 days but it still works on 1.6. – Eric Alexander Sep 7 '11 at 17:30
Okay, I added <script src=""></…; <script type="text/javascript"> but redirection piece is still not working. (adding to survey works) – Nancy o'Donnell Sep 7 '11 at 17:38

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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