Make all form fields read-only (client script)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-13-2011 11:49 PM
Hi,
I need to put all the fields of a form read-only. I need to use a client script for that, because in certain case I will need to have some fields editable.
Is there another way than put all the fields in a ui policy (or a client script)?
Is suppose there is a way to do such a thing :
get references to all fields of the form
while(...)
{
referenced field.setreadOnly()
}
Thanks a lot
rgds
Xavier
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-14-2011 07:28 AM
You can!
Use a g_form method to enumerate the editable fields on a form, and then iterate through them, setting them as read-only.
var fields = g_form.getEditableFields();
for (var x = 0; x < fields.length; x++) {
g_form.setReadOnly(fields[x], true);
}
Let me know if that works.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-02-2014 09:58 AM
Hi Simon,
How about if I wanted to leave a few fields as editable and the rest as read-only?
This would help in cases where the form has 70+ fields but only about 5 need to be editable.
Any suggestions?
RV
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-02-2014 10:27 AM
Then after that loop that was posted above, specifically call out the fields you want to have writable and set them.
Ie: g_form.setReadOnly('field1', false); // now it's not readonly
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-02-2014 10:43 AM
Thank you.