locked
How to enable or disable a textbox onchange... RRS feed

  • Question

  • i have an option on my application that if not on the list select others and i have a fields that type info for that other items.
    Zosimo D. Recio Jr. Microsoft Certified (Business Management Solutions specialist)
    Tuesday, September 8, 2009 5:20 AM

Answers

  • on the onchange event of the picklist (check the datavalue in the picklist)

    setControlEnabled(<textbox>,true/false)
    setControlEnabled = function(fieldObject, enabled)
    {
        fieldObject.disabled = !enabled;

        if (!enabled && fieldObject.className.indexOf("ms-crm-Text") >= 0) {
            // append readonly property to className if not already there
            if (fieldObject.className.indexOf("ms-crm-ReadOnly") < 0)
                fieldObject.className += " ms-crm-ReadOnly";
        }
        else
            fieldObject.className = fieldObject.className.replace(/ ms-crm-ReadOnly/gi, "");
    }


    Tiaan van Niekerk http://crmdelacreme.blogspot.com Skype:tiaan.van.niekerk1
    Tuesday, September 8, 2009 5:50 AM

All replies

  • hi
    look at my blog there is a example for you
    Tiaan van Niekerk http://crmdelacreme.blogspot.com Skype:tiaan.van.niekerk1
    Tuesday, September 8, 2009 5:39 AM
  • hello.. what was the site? i was trying to check the blog site but it was an error.. thank you..

    Zosimo D. Recio Jr. Microsoft Certified (Business Management Solutions specialist)
    Tuesday, September 8, 2009 5:45 AM
  • on the onchange event of the picklist (check the datavalue in the picklist)

    setControlEnabled(<textbox>,true/false)
    setControlEnabled = function(fieldObject, enabled)
    {
        fieldObject.disabled = !enabled;

        if (!enabled && fieldObject.className.indexOf("ms-crm-Text") >= 0) {
            // append readonly property to className if not already there
            if (fieldObject.className.indexOf("ms-crm-ReadOnly") < 0)
                fieldObject.className += " ms-crm-ReadOnly";
        }
        else
            fieldObject.className = fieldObject.className.replace(/ ms-crm-ReadOnly/gi, "");
    }


    Tiaan van Niekerk http://crmdelacreme.blogspot.com Skype:tiaan.van.niekerk1
    Tuesday, September 8, 2009 5:50 AM