Friday, January 17, 2014

How To Hide Save & Close For Surveys Using JavaScript

Hello Inter-webs!

Why Hide The Save & Close Button?

Before I jump into the how, lets talk about the why.  The main reason to hide the Save and Close button is due to the issues it causes for Site Admins and their users.  When a user selects Save and Close instead of selecting Finish, SharePoint treats the survey response as a working draft.  That means that the only individual who can actually access or even see the survey is the individual who created it.  Even as a site collection administrator you can only see the correct number of surveys by navigating to the /_layouts/viewlsts.aspx.  This will show you the total responses including the "drafts" but you still can't access them, so its better to hide the button all together!

How To Hide The Save and Close Button

To hide the Save and Close button you will need to:

  1. Upload the JavaScript file to your Style Library
  2. Place a Content Editor Web Part on your New & Edit forms for your survey
  3. Link the Content Editor Web Parts to the JavaScript file
  4. Hide each Content Editor Web Part
JavasScript Needed:  Save this Script into a .txt file and save it to your Assets Library

<script type=”text/javascript”>
 var x=document.getElementsByTagName(“input”);
 for (var i=0; i<x.length; i++)
 if (x.item(i).type==”button” && x.item(i).value==”Save and Close”)


No comments:

Post a Comment