1

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">
$(document).ready(function(){
// 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));
//window.location.replace("/ThankYou.aspx");
return true;
};
$("#ctl00_m_g_f46a290b_d993_4347_a2da_868aff18de82_ctl00_toolBarTbltop_RightRptControls_ctl01_ctl00_diidIOSaveItem").unbind("click", oldHandler).click(newHandler);
});
</script>
0

2 Answers 2

1
javascript: {ddwrt:GenFireServerEvent('__commit;__redirect={../../Pages/SurveyWirelessThankYou.aspx}')}

I tried this steps from this link (http://social.msdn.microsoft.com/Forums/nl-BE/sharepoint2010general/thread/77009cb5-4951-427d-8c23-5a75aff74290) 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
0

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.

http://sharepoint.mycompany.com/sites/mysite/lists/survey/NewForm.aspx?Source=http://http://sharepoint.mycompany.com/sites/mysite/Lists/survey/ThankYou.aspx

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

<script type="text/javascript">
$(document).ready(function() {
   $("a[href*='NewForm.aspx']").click(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);
   });
});
</script>
11

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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