Your achievements

Level 1

0% to

Level 2

Tip /
Sign in

Sign in to Community

to gain points, level up, and earn exciting badges like the new
Bedrock Mission!

Learn more

View all

Sign in to view all badges

SOLVED

Greying out the fields

Icobbne
Level 3
Level 3

Hi,

If  "Yes" selected all fields below will be greyed out. How can I do that?

greyedout.jpg

1 Accepted Solution
Steve_L_Walker
Correct answer by
Level 10
Level 10

I assume greyed out includes making the fields protected as well.

Untitled.png

The code below sets the each fields access property to "readOnly" and the raw value to null, as well as setting the rectangle object surrounding the fields to a shade of grey, when the user selects "Yes". If the users selects "No" the fields are made user entered optional by resetting the access property and the rectangle is set to white.

// form1.page1.subform1.australianCitizen::change - (JavaScript, client)

if (this.rawValue == "1") {

  form1.page1.subform1.passportNumber.access = "readOnly";

  form1.page1.subform1.expiryDate.access = "readOnly";

  form1.page1.subform1.visaType.access = "readOnly";

  form1.page1.subform1.visaSubclass.access = "readOnly";

  form1.page1.subform1.passportNumber.rawValue = null;

  form1.page1.subform1.expiryDate.rawValue = null;

  form1.page1.subform1.visaType.rawValue = null;

  form1.page1.subform1.visaSubclass.rawValue = null;

  xfa.resolveNode("form1.page1.subform1.box.value.rectangle.fill.color").value = "240,240,240";

}

else {

  form1.page1.subform1.passportNumber.access = "";

  form1.page1.subform1.expiryDate.access = "";

  form1.page1.subform1.visaType.access = "";

  form1.page1.subform1.visaSubclass.access = "";

  xfa.resolveNode("form1.page1.subform1.box.value.rectangle.fill.color").value = "255,255,255";

}

Steve

View solution in original post

2 Replies
Steve_L_Walker
Correct answer by
Level 10
Level 10

I assume greyed out includes making the fields protected as well.

Untitled.png

The code below sets the each fields access property to "readOnly" and the raw value to null, as well as setting the rectangle object surrounding the fields to a shade of grey, when the user selects "Yes". If the users selects "No" the fields are made user entered optional by resetting the access property and the rectangle is set to white.

// form1.page1.subform1.australianCitizen::change - (JavaScript, client)

if (this.rawValue == "1") {

  form1.page1.subform1.passportNumber.access = "readOnly";

  form1.page1.subform1.expiryDate.access = "readOnly";

  form1.page1.subform1.visaType.access = "readOnly";

  form1.page1.subform1.visaSubclass.access = "readOnly";

  form1.page1.subform1.passportNumber.rawValue = null;

  form1.page1.subform1.expiryDate.rawValue = null;

  form1.page1.subform1.visaType.rawValue = null;

  form1.page1.subform1.visaSubclass.rawValue = null;

  xfa.resolveNode("form1.page1.subform1.box.value.rectangle.fill.color").value = "240,240,240";

}

else {

  form1.page1.subform1.passportNumber.access = "";

  form1.page1.subform1.expiryDate.access = "";

  form1.page1.subform1.visaType.access = "";

  form1.page1.subform1.visaSubclass.access = "";

  xfa.resolveNode("form1.page1.subform1.box.value.rectangle.fill.color").value = "255,255,255";

}

Steve

View solution in original post

Icobbne
Level 3
Level 3

Hi Steve,

I really appreciate your time for this solution. Thanks very much