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

Parents
  • 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[i]);
    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[i]);
    input.getElementsByTagName("input")[0].disabled = true;
     
    So I replaced this two lines with below line and it works.
     
    document.forms.MainDataForm.elements[fieldName[i]].disabled = true;
     
     
    Thank You
    Gopikrishnan R
  • Hi Gopikrishnan,

    your code worked perfectly.

    Thank you for your help, I appreciate that.

    David

Reply Children