Changing PickList Values on Yes/No Form Field Change
Recently on the Microsoft forums someone asked how to change the values of a picklist based on the yes no value of a boolean field. Just add this script to the OnChange event of the yes/no field.
This technet page shows some of the functions on different form fields.
Here is an example of how to change the picklist based on a yes/no field:
function CreatePicklistValue(Name,Value)
{
var retval = new Array();
retval[0] = Name;
retval[1] = Value;
return retval;
}
function BuildPickList(picklist, valuelist)
{
var options = picklist.Options;
for(var i=0; i<options.length; i++)
{
var option = options[i];
picklist.DeleteOption(option.DataValue);
}
for(var j=0; j<valuelist.length; j++)
{
var listitem = valuelist[j];
picklist.AddOption(listitem[0], listitem[1]);
}
}
var lista = new Array();
lista[0] = CreatePicklistValue('Alpha',0);
lista[1] = CreatePicklistValue('Beta',1);
var listb = new Array();
listb[0] = CreatePicklistValue('Charlie',2);
listb[1] = CreatePicklistValue('Delta',3);
var uselista = crmForm.all.YesNo.DataValue;
var picklist = crmForm.all.Picklist;
if (uselista==true) {
BuildPickList(picklist, lista);
} else {
BuildPickList(picklist, listb);
}
You just need to change the values of lista and listb, and the crmForm.all.YesNo and crmForm.all.Picklist.