locked
how to hide/display controls in EditForm.aspx based on dropdown value in SharePoint list RRS feed

Answers

  • Hi Pepsin,

    Try following code

    <script language="javascript" type="text/javascript"> 
    _spBodyOnLoadFunctionNames.push("hideFields");
    function findacontrol(FieldName)
    {
    var arr = document.getElementsByTagName("!");
    for (var i=0;i < arr.length; i++ )
    {
    if (arr[i].innerHTML.indexOf(FieldName) > 0)
    {
    return arr[i];
    }
    }
    }
    function hideFields()
    {
    var
    control = findacontrol("Column Name 1");
    control.parentNode.parentNode.style.display="none";
    control = findacontrol("Column Name 2");
    control.parentNode.parentNode.style.display="none";
    }
    </script>

    Replace Column name with your form's column.
    Hth

    Warm Regards, Pratik Vyas | SharePoint Consultant | http://sharepointpratik.blogspot.com/ | Posting is provided "AS IS" with no warranties, and confers no rights
    Tuesday, November 8, 2011 6:40 PM