Expand my Community achievements bar.

SOLVED

Greying out the fields

Avatar

Level 3

Hi,

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

greyedout.jpg

1 Accepted Solution

Avatar

Correct answer by
Former Community Member

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

Avatar

Correct answer by
Former Community Member

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

Avatar

Level 3

Hi Steve,

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

The following has evaluated to null or missing: ==> liqladmin("SELECT id, value FROM metrics WHERE id = 'net_accepted_solutions' and user.id = '${acceptedAnswer.author.id}'").data.items [in template "analytics-container" at line 83, column 41] ---- Tip: It's the step after the last dot that caused this error, not those before it. ---- Tip: If the failing expression is known to be legally refer to something that's sometimes null or missing, either specify a default value like myOptionalVar!myDefault, or use <#if myOptionalVar??>when-present<#else>when-missing. (These only cover the last step of the expression; to cover the whole expression, use parenthesis: (myOptionalVar.foo)!myDefault, (myOptionalVar.foo)?? ---- ---- FTL stack trace ("~" means nesting-related): - Failed at: #assign answerAuthorNetSolutions = li... [in template "analytics-container" at line 83, column 5] ----