Link to home
Start Free TrialLog in
Avatar of Steve Sirica
Steve SiricaFlag for United States of America

asked on

Emulate Postback of "All Day Event" in custom list form

I have a Calendar list for time off request.  I don't need a couple of the fields on the default NewForm.aspx so I did the whole "New From Existsing Page", delete the default content on the page and inserted a new custom sharepoint control based on a new calendar item.  That all works great, except now I lost the postback date altering behavior of the "All Day Event" checkbox.  How can I progrmatically recreate that?  
I am using SharePoint Designer to alter my pages.

Thanks Steve
Avatar of dp_expert
dp_expert
Flag of Poland image

I don't think you can.

The other option to modify the form is to hide fields with javascript. Revert your new/edit form to the default web part. In the snippet you will find a function that searches for form fields and changes their "display" style to "none". With SPD add at the end of the file the code and call the document.getElement... line for every field you would like to hide.
The title of the element is usualy its display name. To be sure - find the title of the element by viewing the source of the add/edit page and search for the name of the column.
document.getElementById(get_form_elem_id("Title of element 1").style.display='none';
document.getElementById(get_form_elem_id("Title of element 2").style.display='none';
 
function get_form_elem_id(title)
   {
 
	//take the form elements collection
    var elem = document.forms[0].elements;
 
	//do a loop
	for(var i = 0; i < elem.length; i++)
	{
 
	  //if the title is equal to the searched title
	  if(elem[i].title==title)
	  {
	    //return the id of the searched element
	    return elem[i].id;
	  }	  
	} 
	return false;
   }

Open in new window

Avatar of Steve Sirica

ASKER

That only partially worked.  Your solution took care of the field only and only if it has a Title.  I actually found a better solution: http://moblog.bradleyit.com/2008/10/disabling-workspaces-from-sharepoint.html?showComment=1224610080000

It works great.  Thanks for you help anyway.
ASKER CERTIFIED SOLUTION
Avatar of dp_expert
dp_expert
Flag of Poland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial