Copy link to clipboard
Copied
I'm new to JS, learning as i go, and i'm stuck on this one. Hopefully someone could help?
This is the script I currently have:
var fieldsToLock = ["Text2", "Text1", "Text3", "Text4", "Text5", "ComboBox6", "MRcheck", "CustomerCheck", "Other2check", "SubCombo", "RadCombo", "ProcCombo", "ForCombo", "BackCombo", "BordCombo", "MounCombo", "Text39", "Text7", "Customchk", "exttypecombo", "extforecombo", "extbackcombo", "extlogocombo", "extchevcombo", "exttapercombo", "extmoutcombo", "extSSchk", "extDSchk", "extaddition", "Text32", "decRadCombo", "decProcCombo", "decBordCombo", "decText39", "Text41", "UpholsteryCombo", "Fencelength", "fencebetween", "Text47", "Text48", "Text6", "Text8", "CheckBox9", "CheckBox10", "sizefield", "sizefieldother", "sizefielddec", "Text10", "Text11", "Text12", "Text13", "Text14", "Text15", "flatSSchk", "flatDSchk", "heightdecfield", "heightotherfield", "heightfieldflat", "bannerheight", "Text41", "fenceheightfield", "ReflectivityCombo", "OverlayCombo", "Text1", "decForCombo", "decBackCombo", "decRadCombo", "decProcCombo", "banText39", "FlatCheck", "ExtCheck", "DecalCheck", "BannerCheck", "Other1check", "Text17", "Text91", "Text101", "Text111", "CheckBox11" ];
for (var i in fieldsToLock) this.getField(fieldsToLock).readonly = true;
There are a lot of fields to be made read only, but there are some not shown here, which i need to stay writable. It works for about 75% of the fields but not the others. I've checked all the names are correct. What else could be causing this? And is there any way around the problem?
Copy link to clipboard
Copied
There's probably a typo in your code, such as an incorrect field name. To check, open the interactive JavaScript console by selecting Ctrl+J.
Note that if you use hierarchical field naming, you can control a group of field with a single statement. For example, if you had fields named "Group1.Text1", "Group1.Text2", "Group1.Fencelength", you can set them all to read-only like this:
getField("Group1").readonly = true;