Thursday, June 10, 2010

Quick JavaScript: Setting Read Only Colors

Code to set a field to read only (you can also use disabled) and update the field colors to match the colors of other read only fields on the same form.


crmForm.all.estimatedvalue.disabled = true;
crmForm.all.estimatedvalue.style.textColor= "#000000";
crmForm.all.estimatedvalue.style.borderColor= "#C5C5C5";
crmForm.all.estimatedvalue.style.backgroundColor = "#EAF3FF";

NOTE: Using the disabled property is generally better than the readOnly property because it sets some of the color attributes correctly leaving only a few for you to set on your own. Also, keep in mind that different field types (Picklists, Lookups, etc) behave somewhat differently.

As an aside, all of the standard colors can be found in the CRM SDK.


Copyright ©2010 Kumar Blog

No comments:

Post a Comment