1

I asked this question in the main SOF forum but I think it belongs here.

https://stackoverflow.com/questions/10415929/sharepoint-2003-presaveaction

I need to add a little JavaScript to run when user clicks "Save and Close". I know in SharePoint 2010 I could just use PreSaveAction() but I am using 2003.

Pseudo:

user clicks save and close
if attachment exists
  add the list entry
else 
  alert the user to upload attachment

It looks like the function ClickOnce() is what triggers the form to save since the button href="javascript:ClickOnce()". So what I did was change the href of this link to my own function unless attachment exists. This did not work because it would either do nothing or fire when the page loaded whether there was an attachment or not.

Anyone have a workaround for this?

0

You could use jQuery to change the HREF on the save button to first call your javascript and then call the ClickOnce() function.

Something like:

href="javascript:YourFunction();ClickOnce();"
  • This didnt work either. I think SharePoint javascript is running after mine and overwriting the href. – Jonathan Eckman May 2 '12 at 17:56
  • Use a JavaScript timeout to set your HREF 200-300 MS after the page loads. That should give it enough time for SharePoint to do its thing, but quick enough that the user won't click the button before then. – John Chapman May 2 '12 at 19:02
  • The timeout made it work. – Jonathan Eckman May 4 '12 at 13:39

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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