Thursday, August 23, 2012

How to make Read Only Tab in CRM? How to Make read only all the attribute in a specified Tab?

Use the following line of code to make all the fields within a tab as read only or disabled.

// get the div element corresponding to tab, first tab would have index tab0, second as tab1 and so on ..
var el=document.getElementById('tab2')

// create a recursive function to Disable Attributes
function toggleDisabled(el) {
try {
el.disabled = el.disabled ? false : true;
}
catch(E){}
if (el.childNodes && el.childNodes.length > 0) {
for (var x = 0; x < el.childNodes.length; x++) {
toggleDisabled(el.childNodes[x]);
}
}
}

// create a recursive function to Enable Attributes
function toggleEnabled(el) {
try {
el.disabled = el.disabled ? true : false;
}
catch(E){}
if (el.childNodes && el.childNodes.length > 0) {
for (var x = 0; x < el.childNodes.length; x++) {
toggleEnabled(el.childNodes[x]);
}
}
}

No comments: