Tuesday, 20 October 2009

MS Dynamics 4.0 - Show/Hide Field Dependant On Picklist Value

Hi,

In the below example, i had a list of 5 values stored in a field as a picklist. When values 1 and 2 were chosen i wanted to hide the field, and display it when values 3,4 and 5 are selected. If you only have a single value to hide the field, then simple remove the "if else" part of the code below...


if(crmForm.all.cit_phonestatus.DataValue == 1)
{
    crmForm.all.cit_dateret.disabled = true; // to disable

    // to hide
    crmForm.all.cit_dateret.style.display = "none";
    crmForm.all.cit_dateret_c.style.display = "none"; // for label
}
else if(crmForm.all.cit_phonestatus.DataValue == 2)
{
    crmForm.all.cit_dateret.disabled = true; // to disable

    // to hide
    crmForm.all.cit_dateret.style.display = "none";
    crmForm.all.cit_dateret_c.style.display = "none"; // for label
}

else {

crmForm.all.cit_dateret.disabled = false;
    crmForm.all.cit_dateret.style.display = "";
    crmForm.all.cit_dateret_c.style.display = "";
}

No comments:

Post a Comment