Is there a way to make a field read-only from a table that is dynamic. In the sense that more rows can be added. I attempted treat this as if it was a normal text field by using javascript to make it read-only and this did not work. Would I have to have a loop to change the input box to read-only?
Question
Question
Is there a way to make a dynamic table field read-only?
Answer
Give the field a CSS class like read-only. Then you can use JavaScript like
$(document).ready(function () { $('.read-only input').attr('readonly',true); $('.cf-table-add-row').click(function () { $('.read-only input').attr('readonly',true); }); });
The idea is that the initial fields with the read-only CSS class will be read only. Then, when you click the "Add" button to add more rows to the table, it will make any new fields with the read-only CSS class read only.
Would this be the same Javascript if the Table is filled from a Lookup Rule? I can only get the first row to be read only.
Thanks
I have the same question as @████████. How would you alter this to work if the table is being populated from a lookup rule?
Replies
Hi there,
I'm interested to know what's your real world use case for dynamic table, and which part is read-only?
The table is required to be dynamic to add extra entries to it. It is initially doing a calculation for the total per row. These totals per each row have been requested to be read-only so the user is not able to cause any errors or attempt to change the total that had been calculated. The reason for utilizing javascript or css to change the field to read-only is that there were issues before when storing the form to the repository and not saving the calculated totals. This can be used in such cases for expense reports, stock buying/selling calculations, or gas reimbursement. The reason for the calculation per row is that it was decided upon to be able to see each expense per row so auditors or approvers could identify each row total instead of having to calculate it themselves and not only have an overall total to look at.
thanks! Can you share a screenshot of the table if possible?
Here is a snippet of the area for what it looks like.
thanks!
I use this to verify that the lookup process on the field value that the user supplied returned a value from the database and populated the table row read-only field. Otherwise the user entered an invalid field value and the form should not be submitted.