Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

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>
share|improve this question
add comment

2 Answers 2

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
share|improve this answer
add comment

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>
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. –  PirateEric Sep 7 '11 at 17:30
    
Okay, I added <script src="ajax.aspnetcdn.com/ajax/jquery/jquery-1.6.min.js"></…; <script type="text/javascript"> but redirection piece is still not working. (adding to survey works) –  Nancy o'Donnell Sep 7 '11 at 17:38
show 6 more comments

Your Answer

 
discard

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.