Popular Posts

Thursday, March 31, 2011

Hide Save Button in SharePoint Survey

Today i try to check number of response in survey. From view all site content, i browse to my survey list.
I notice the number responses shown in 5. 

I click on survey and notice is there is only 2 responses. I search around and found that it is design behavior claimed by Microsoft.  

It has same behavior in new SharePoint 2010 !?!

To overcome it, there are 2 ways. 
1) Add javascript in both NewForm.aspx and EditForm.aspx using SharePoint Designer or in Content Editor Web Part.

i) 
_spBodyOnLoadFunctionNames.push('hideSave');

function hideSave()
{
 var tags=document.getElementsByTagName('input');

 for(var i=1; i<tags.length; i++)
 {
/* For WSS 3.0 / MOSS 2007*/
  if(tags[i].value=='Save')
  {
   tags[i].style.visibility='hidden';
  }
/*For SharePoint 2010*/
  if(tags[i].value=='Save and Close')
  {
   tags[i].style.visibility='hidden';
  }
 } 
}

ii)
_spBodyOnLoadFunctionNames.push("setValue");
function setValue() {
/*for WSS 3.0, MOSS 2007*/
hideButton("Save");

/*for SharePoint 2010*/
hideButton("Save and Close");

}

//This function hides a button on the page
function hideButton(valueDef){
var frm = document.forms[0];
for (i=0;i< frm.elements.length;i++) {
if (frm.elements[i].type == "button" && frm.elements[i].value == valueDef) {
frm.elements[i].style.display = "none";
}
}
}

2) use jQuery


   

No comments:

Post a Comment