You are viewing limited content. For full access, please sign in.

Question

Question

Mark a Cell Read-Only with Default Value in a Table

asked on September 17, 2019

Hi Everyone,

 

We have a typical requirement for one of the cases where a Table which contains Columns from two sources for matching and Results of matching. All these column values are updated by Workflow.

 

While the task gets assigned to a user to review "False" ones, it is mandatory for him to give remarks.

1. If we make this column mandatory then he will require to enter some text even for TRUE ones

2. If we pass Default Value to the Column then even FALSE gets the default text thus allowing him to submit the form without possibly through review.

I am new to Java Scripting and thus it will be great if you help me achieve this, where Remark Cells gets set to value "Not Required" if Result Cell is "True" and set the cell to Read-Only.

Appreciate your help. Thank you. 

 

Warm Regards,

Chandresh

Table Illustration.png
0 0

Replies

replied on September 27, 2019 Show version history

@████████- I think this might achieve what you are desiring.

This assumes that your two fields have CSS Class Names of resultField and remarksField.

$(document).ready(function () {
    
  //When form loads, check every one of the fields with the resultField class.
  //If the value of the field is TRUE, locate the closest field with the remarksField class,
  //and populate it with the words "Not Required" and make it readonly.
  $('.resultField input').each(function() { 
    if ($(this).val() == 'TRUE') { 
      $(this).closest('tr').find('.remarksField input').val('Not Required');
      $(this).closest('tr').find('.remarksField input').attr('readonly', 'true');
    }
  });
  
  //When any resultClass field is changed.
  //If the value of the field is TRUE, locate the closest field with the remarksField class,
  //and populate it with the words "Not Required" and make it readonly.
  //Otherwise, clear the remarksField and make it editable.
  $('.resultField input').change(function() { 
    if ($(this).val() == 'TRUE') { 
      $(this).closest('tr').find('.remarksField input').val('Not Required');
      $(this).closest('tr').find('.remarksField input').attr('readonly', 'true');
    }
    else { 
      $(this).closest('tr').find('.remarksField input').val('');
      $(this).closest('tr').find('.remarksField input').removeAttr('readonly');
    }
  });
    
});

 

0 0
You are not allowed to follow up in this post.

Sign in to reply to this post.