Friday, October 24, 2008

Crm 4- Simple Function to Hide Attributes on A Form

Yesterday we had a project where a requirement was to 'filter' attributes on the form based on a picklist value. To accomplish this, a function to hide the attributes should be created. Opening the form source, we see that all form attributes have an ATTRIBUTE_NAME_d and an ATTRIBUTE_NAME_c id tag. One is for the label and the other is for the input (TextArea, Date field, etc). So the Javascript looks like this:

//Hides attributes on form
function HideAttributeOnForm(sAttributeName)
{
document.getElementById(sAttributeName + '_d').style.display = 'none';
document.getElementById(sAttributeName + '_c').style.display = 'none';
}

To use this, simply pass in the attribute name:

HideAttribute("YOUR_ATTRIBUTE_AS_A_STRING");

No comments: