Forum Discussion

Dave259's avatar
Dave259
Ideator I
6 years ago

Disable more than one text field on the form

Hi Community,

I am using a code from the "Disable Form Fields"-blog (https://community.aras.com/b/english/posts/disable-form-fields/) in one of my methods. In the test phase I realized that the code for the text field only works on one field.

I tried to call all the required fields in the brackets, but it always used only one field:

var input = getFieldByName("part", "part_number", "quantity");
input.getElementsByTagName("input")[0].disabled = true;

How can I easily disable multiple fields at the same time on the form?

Thank you in advance for your help!

Best regards

David

4 Replies

  • Hi David

    You can try something like below

    var columnsName = ["part", "part_number","quantity"];
    var setFieldDisabled = function(fieldName)
    {
    for (i = 0; i < fieldName.length; i++)
    {
    var input = getFieldByName(fieldName);
    input.getElementsByTagName("input")[0].disabled = true;
    }
    };
    setFieldDisabled(columnsName);
    return this;
    I'm not sure what version of ARAS you are using but below lines does not work for my version.
    var input = getFieldByName(fieldName);
    input.getElementsByTagName("input")[0].disabled = true;
     
    So I replaced this two lines with below line and it works.
     
    document.forms.MainDataForm.elements[fieldName].disabled = true;
     
     
    Thank You
    Gopikrishnan R
    • Dave259's avatar
      Dave259
      Ideator I

      Hi Gopikrishnan,

      your code worked perfectly.

      Thank you for your help, I appreciate that.

      David

      • Gopikrishnan's avatar
        Gopikrishnan
        Ideator I

        Glad to help [emoticon:c4563cd7d5574777a71c318021cbbcc8]

        Thanks

        Gopikrishnan R