2010-06-22

How to hide a section or field by picklist value

That code snippet will hides a section by name(label) or by label of any field wich is in this section.
if(crmForm.all.new_1!=null)
{
 var oField = crmForm.all.new_1;
 
 // field to hide
 var FieldToHide;
 if(document.getElementById("IDENT") != null)
 {
  FieldToHide = document.getElementById("IDENT");
  FieldToHide.style.display = "block";  
 }
 
 
 // section to hide
 var td = document.getElementsByTagName("td");
 var tableH;
 for(var i=0; i<td.length; i++)
 {
  // enter the correct section name
  if(td[i].innerText == "Section name")
  {
   tableH = td[i].parentNode.parentNode.parentNode;
   tableH.style.display = "block";
  }
 }
 
 
 // here set the needed picklist value
 if(oField.DataValue == 1)
 {
  // field to hide
  if(FieldToHide != null)
  {
   FieldToHide.style.display = "none";  
  }
 }
 else
 if(oField.DataValue == 3)
 {
  // section to hide
  if(tableH != null)
  {
   tableH.style.display = "none";
  }

 }
}

2010-06-10

Tooltip

To add a tooltip at some field on form, jast add next snippet with your changes to form On Load

var ele = document.getElementById("firstname_c");
ele.title = "Name Name Name!";