Problem with disabled select.

Problem with disabled select.

Hi everybody,
I have a problem with disabled select, input text and textarea. These elements are in a form in a dialog form. When I open the dialog I control if the input text is not empty. If the condition is true  I need to disabled input text, text area and select. It works fine. But If I open the diagol again it doesn't work, I mean that the elements are not disabled.

This is the code to disabled the 3 elements:
for (i=1;i<=10;i++)
    {
      for (j=1;j<=10;j++)
      {   
        if ($("#matt"+i+j).val() > '')
        {
            $('#matt'+i+j).attr('disabled', 'disabled');
            $('#prof'+i+j).attr('disabled', 'disabled');
        }
      }
    }
   
    for (i=1;i<=10;i++)
    {
      if ($("#matt"+i+1).val() > '')
      {   
        $('#argom'+i).attr('disabled', 'disabled');
      }
    }

Please, can someone helps me?

Many thanks in advance.

Tegatti