Tuesday, January 11, 2011

Loop through all elements on a CRM Form

Sometime we require to set all attributes on a form to disabled or checking which attribute has been changed.

To achieve this, you need to loop through each attribute of the CRM form. Below is the code snippet :


var iLen = crmForm.all.length;

for (i = 0; i < iLen; i++)
{
   o = crmForm.all[i];   switch (o.tagName)
   {
      case "INPUT":
      case "SELECT":
      case "TEXTAREA":
      case "IMG":
      case "IFRAME":
      if (o.id != "leadqualitycode")
      {
            o.disabled = true;
      }
      break;

      default:
            break;
   }
}

The above code will set all attributes to disabled.

No comments: