Reputation: 817
Javascript
I have code that will hide various sections in a MS CRM form based on the value of a Picklist. The code executes in the onChange event of the Picklist. It hides the section by referencing a field in the section and then navigating up the DOM using the ParentElement syntax, as such:
crmForm.all.fieldName.parentElement.parentElement.parentElement.style.display = 'none';
This seems to work, with 1 exception. The offending section has a single read-only field, which I assume is the cause. No error is thrown. I've also tried variations with 2 and 4 ".parentElement" blocks.
How can I hide this section?
Upvotes: 1
Views: 6380
Reputation: 1366
The previous suggestion of hiding by section # will work. Or you could also try using fieldname_c instead of fieldname (and should only need 2 parentElements). _c is the "comment" (label) for the field and should be a bit more consistent.
Upvotes: 0
Reputation: 66
Take a look at the following post. it uses section position instead of parentElement. http://mscrm4ever.blogspot.com/2008/08/show-hide-crm-form-section.html
Upvotes: 1
Reputation: 39291
Sorry, buy can you clean up the question? You say it works with 1 exception when the section has a read-only field. Is that the field you are trying to work with in your example? Or can you work with any field in the section, but if there is one read only in the section it fails? What is the exception (doesn't work, javascript error)?
Upvotes: 0