Expand my Community achievements bar.

Dive into Adobe Summit 2024! Explore curated list of AEM sessions & labs, register, connect with experts, ask questions, engage, and share insights. Don't miss the excitement.

Using scripting to apply the same formatting to multiple fields

Avatar

Former Community Member

I have four text fields that when a certain checkbox (CompleteClosure) is clicked become required, accessible, and have a red border.

When a different checkbox is clicked, they become not required, readOnly, and gray bordered. My scripting on each box contains many lines:

form1.#subform[0].CompleteClosure::click - (JavaScript, client)

Page1.DivisionalClosure.rawValue =0;

Page2.PartialClosure.rawValue = 0;

//DivisionalClosure and PartialClosure are the other checkboxes

Page1.CompleteDate.mandatory = "error";

Page1.CompleteDate.access = "open";

Page1.CompleteDate.border.edge.color.value = "225,0,0";

Page1.CompleteDate.borderWidth = "0.5in";

Page1.ClosureReason.mandatory = "error";

Page1.ClosureReason.access = "open";

Page1.ClosureReason.border.edge.color.value = "225,0,0";

Page1.ClosureReason.borderWidth = "0.5in";

Page1.CompleteCode.mandatory = "error"; 

Page1.CompleteCode.access = "open";

Page1.CompleteCode.borderWidth = "0.5in"

Page1.CompleteCode.border.edge.color.value = "225,0,0";

Page1.ClosureMgr.mandatory = "error";

Page1.ClosureMgr.access = "open";

Page1.ClosureMgr.borderWidth = "0.5in";

Page1.ClosureMgr.border.edge.color.value = "225,0,0";

and this is just for the first checkbox.  Is it possible to group these fields or make them a subform and format them with simply:

Page1.CompSubformName.all.mandatory = "error";

Page1.CompSubformName.all.access = "open";

Page1.CompSubformName.all.border.edge.color.value = "225,0,0";

Page1.CompSubformName.all.borderWidth = "0.5in";

for some reason all the formatting does not occur when this is done.  Is this the right track, or does the coding need to be entered individually for each textfield?

Thanks in advance for any help, I'm new to this and most of the above was crafted from reading helpful info on this site.

Message was edited by: peppemonkey

0 Replies