Saturday, May 5, 2012

Hide/unhide some sections in the sharepoint Forms based on user input

Is there any way to hide/unhide some sections in the sharepoint Forms based on user input?


Suggestions:


(1). If you're using SharePoint 2010 Enterprise, then you can replace the built-in new/edit/view Forms with InfoPath and implement the show/hide logic within InfoPath. Otherwise you will have to customize the NewItem.aspx/EditItem.aspx forms in SharePoint Designer and do the showing/hiding through some custom JavaScript code.

(2) Most basic straightforward would be the use of content types - depending on you specific Needs, different content types will show different fields, so you can associate multiple content types with a single 'choice'. Changing the content type changes the user's choice, and thus the visible fields. It's an extremely limited approach, but it is OOB.


(3) Another approach would be to incorporate custom JavaScript in your forms (you can add a Content editor web part that loads the script) that attaches to the DOM and shows/hides fields based on values in other fields. This approach could require a lot of effort that would also potentially be a pain to maintain.
 
(4) The final approach would be to use some third party tool or solution. There may be Something you could download from Codeplex or elsewhere, but I don't know. I do know that my company has a suite of add-ins to SharePoint that includes the ability to create multiple form sections that can be separated out on different screens, so users could get a different set of fields based on their choices in prior screens. You could also probably hack up a survey list for a similar effect.


(5) You would need to use custom javascript for this, You will have to retrieve the object that you are interested in, Looks like it would be the check box in your case.

--- Once you have the handle on the checkbox, you would need to attach an event on it using
JavaScript which should call a JavaScript function.

--- in the JavaScript function you need to get check if the value of check box is "yes" or "no" and depending on that you will have to hide the fields. (You will have to retrieve the objects from your DOM) once you have the handle on the DOM, you can easily hide it. Let us know if you are still having some issue, may be one of us will post some code for you.
 
 
 

No comments:

Post a Comment