How to change properties for all form fields starting with the same name at the same time?
I am working on a travel form which has 3 different sections: advance, actual, and reconcile. Each section will have it's own set of fields.
I would like to create a button which will set all the advance fields to read only at the same time. Fields are named advance.start_date, advance.end_date, reconcile.total, etc.
Essentially when I click a button to set the advance, it will change all fields starting with advance to read only. I will do the same to set the actual.
The goal is to make the form so that the user can't change the advance details after once committed. I realize that read only can be undone by editing the form setup and unchecking read only.
Essentially I know I need a javascript to do the following:
- create an array of fields with the name starting with advance.
- loop through the array
- extract the field name
- execute this.getField("fieldName").readonly = true;
- exit the loop
