Expand my Community achievements bar.

Learn about Edge Delivery Services in upcoming GEM session
SOLVED

Formatting specific DD list entries

Avatar

Level 2

Based on the selection in one DD list (named "Priority"), we are using the code below to populat another DD list (named "WOresolution14") with specific list items:

form1.Page1.Subform-Page1-Info.Priority::exit - (JavaScript, client)

//Clear out the WOresultion14 DDlist

WOresolution14.rawValue

= "";

WOresolution14.clearItems();

//Set the WOresolution14 DDList based on the value selected in the Priority DDlist

switch

(this.rawValue)

{

case "Critical":

WOresolution14.addItem("Less than 15 min");

WOresolution14.addItem("15-30 min");

WOresolution14.addItem("30min - 1 hr");

WOresolution14.addItem("1-2 hrs");

WOresolution14.addItem("More than 2 hrs");

break;

case "Urgent":

WOresolution14.addItem("Less than 2 hrs");

WOresolution14.addItem("2-3 hrs");

WOresolution14.addItem("3-4 hrs");

WOresolution14.addItem("4-5 hrs");

WOresolution14.addItem("More than 6 hrs");

break;

}

________________________________________

WHAT WE WANT TO DO:

We want to format specific items in the 2nd DD list ("WOresolution") so when that particular item is selected, it appears in bold formatting... or the DD list background turns RED colour.  ONLY when a particular item is selected, not for all items.  This is to provide a visual cue when the item is selected.

1 Accepted Solution

Avatar

Correct answer by
Level 10

Hi,

In the exit event of Priority dropdown you would include additional script after the clearItems() script.

Along the lines of:

var vName = WOresolution.somExpression;

var fieldObj = xfa.resolveNode(vName + ".ui.#choiceList.border.fill.color");

fieldObj.value = "255,255,225";

WOresolution.font.weight = "normal";

Hope that helps,

Niall

View solution in original post

13 Replies

Avatar

Level 10

Hi,

Here is a sample: https://acrobat.com/#d=ElcyXeDoKUzc1DVJ1kHaRA

Script is in the exit event of the dropdown and can be amended to suit.

Niall

Avatar

Level 2

This does the majority of what we're looking for, thanks!

However, there are some minor things I need help in cleaning up.

Here's what happens:

1.  In DDlist "Priority" : select item "Critical"

2.  In DDlist "WOresolution" : 5 corresponding items appear.

3.  In DDlist "WOresolution" : select item "More than 2 hrs"

4.  In DDlist "WOresolution" : As per my coding, background colour turns red and font is bolded.

5.  In DDlist "Priority" : select any other item (e.g., "Urgent")

6.  In DDlist "WOresolution" : background colour remains last colour (in this case, red), font of items remains last weight (in this case, bold).

WHAT I'M LOOKING FOR:

Whenever I select a new item from DDlist "Priority", DDlist "WOresolution14" will return to white background, and the items in the list will return to normal weight.

Avatar

Correct answer by
Level 10

Hi,

In the exit event of Priority dropdown you would include additional script after the clearItems() script.

Along the lines of:

var vName = WOresolution.somExpression;

var fieldObj = xfa.resolveNode(vName + ".ui.#choiceList.border.fill.color");

fieldObj.value = "255,255,225";

WOresolution.font.weight = "normal";

Hope that helps,

Niall

Avatar

Level 2

PERFECT !!!

Thank you VERY much, Niall 

Avatar

Level 2

I'm TRYING not to push my luck with the goodwill of the fine folks here.

I have a reset button on this form that clears out the fields when it is clicked.

The code for the reset button is:

________________________________

form1.Page2.Subform-Page2-info.ResetButton1::click - (JavaScript, client)

xfa.host.resetData();

________________________________

When I click the Reset button, the WOresolution14 DD list still does the following:

a) retains the last fill colour (e.g. in some cases, red)

b) retains the last font weight (e.g., in some cases, bold)

c) the value "0" appears in the field

d) if I click the DDlist, the list of items corresponding to the last "Priority" field setting appear

The Reset button and the field WOresolution14 are on different pages, in different subforms.

HERE'S WHAT I'M LOOKING FOR:

When I click the Reset button, the WOresolution14 field returns to white fill colour, there is no value in the field, no selection items are in the field, and the font weight returns to normal.

Tried this without luck:

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

form1.Page2.Subform-Page2-info.ResetButton1::click - (JavaScript, client)

xfa.host.resetData();

//Clear out the WOresultion14 DDlist

WOresolution14.rawValue = "";

WOresolution14.clearItems();

var

vName = WOresolution14.somExpression;

var

fieldObj = xfa.resolveNode(vName + ".ui.#choiceList.border.fill.color");

fieldObj.value

= "255,255,255";

WOresolution14.font.weight

= "normal";

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Avatar

Level 10

Hi,

Glad you have it working.

You are very much on the right track, adding the script after the reset.

The only issue is that you need to provide a fuller reference because  the reset button and the dropdown are on different pages.

There is a very handy trick to insert the right amount of reference into a script.

  1. Select the reset button and scroll the form up until you can see the dropdown.
  2. Then go into the script window (when the reset button is still selected) and press and hold the Control key.
  3. Now when you hover over the dropdown, the mouse changes into a 'V'.
  4. Click the dropdown (while still holding the Control) and LC designer will automatically insert enough reference for the dropdown into the script in the reset button.

It will probably look something like: page1.subform2.WOresolution14

You should have the fuller reference everywhere you are referencing the dropdown. It should work then,

Niall

Avatar

Level 2

Great trick. 

The path was indeed similar.

Here's the code I tried for the Reset button... still doesn't work though:

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

form1.Page2.Subform-Page2-info.ResetButton1::click - (JavaScript, client)

xfa.host.resetData();

xfa.resolveNode("Page1.Subform-Page1-Info.WOresolution14")

//Clear out the WOresultion14 DDlist

WOresolution14.rawValue = "";

WOresolution14.clearItems();

var vName = WOresolution14.somExpression;

var fieldObj = xfa.resolveNode(vName + ".ui.#choiceList.border.fill.color");

fieldObj.value = "255,255,255";

WOresolution14.font.weight = "normal";

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Unfortunately, it does not work still... the same thing happens when I click the Reset button. 

Avatar

Level 10

Hi,

I would be very surprised if you have to resolve the node,

So try this:

xfa.host.resetData();

//Clear out the WOresultion14 DDlist

Page1.Subform-Page1-Info.WOresolution14.rawValue = "";

Page1.Subform-Page1-Info.WOresolution14.clearItems();

var vName = Page1.Subform-Page1-Info.WOresolution14.somExpression;

var fieldObj = xfa.resolveNode(vName + ".ui.#choiceList.border.fill.color");

fieldObj.value = "255,255,255";

Page1.Subform-Page1-Info.WOresolution14.font.weight = "normal";

Your resolveNode script wasn't doing anything (eg it wasn't assigning the resolved node to a variable). See the difference - hopefully that will work.

Niall

Avatar

Level 2

Hi Niall,

I hope you had a good weekend!

I tried using this code exactly, but unfortunately it is ineffective.  It won't even clear the field contents now.

Avatar

Level 10

Hi,

It looks like the script is falling over.

When previewing the form, open the JavaScript Console by pressing Control+J. When you click the reset button, do you get a warning there.

If you have unnamed subforms between the button and the dropdowns, then you will need to resolve the node. Try setting a variable to the resolved node and then use this variable in the script.

xfa.host.resetData();

var oNode = xfa.resolveNode("Page1.Subform-Page1-Info.WOresolution14")

//Clear out the WOresultion14 DDlist

oNode.rawValue = "";

oNode.clearItems();

var vName = oNode.somExpression;

var fieldObj = xfa.resolveNode(vName + ".ui.#choiceList.border.fill.color");

fieldObj.value = "255,255,255";

oNode.font.weight = "normal";

Hopefully that will work for you.

Busy weekend!

Niall

Avatar

Level 2

Weirdness is going on.

When I preview I get this in the JavaScript Debugger console window:

Acrobat EScript Built-in Functions Version 9.0
Acrobat Annotations / Collaboration Built-in Functions Version 9.0
Acrobat Annotations / Collaboration Built-in Wizard Functions Version 9.0
Acrobat SOAP 9.0

RegularAccessSubform is not defined
1:XFA:form1[0]:initialize

BUT I went into the "form" item in hierarchy and wiped out all the subform initialization stuff there... old leftovers from another form.

However, it keeps appearing.

Then, I fill in the form, and click the RESET button... and a new item appears in the console:

invalid assignment left-hand side
5:XFA:form1[0]:Page2[0]:Subform-Page2-info[0]:ResetButton1[0]:click

Avatar

Former Community Member

I would need to see the form to see what id happening .....can you post it to LiveCycle8@gmail.com and I will have a look when I get a chance.

Paul

Avatar

Level 10

Hi,

The first part is standard Acrobat start up:

Acrobat EScript Built-in Functions Version 9.0
Acrobat Annotations / Collaboration Built-in Functions Version 9.0
Acrobat Annotations / Collaboration Built-in Wizard Functions Version 9.0
Acrobat SOAP 9.0

The next line is script in the initialise event of the root node: form1:

RegularAccessSubform is not defined
1:XFA:form1[0]:initialize

You can hit the clear/trash button to clear the window and then when you hit the reset button it will be the only message.

You should look at the script on (or around) Line 5 of the click event. It might be this line:

oNode.rawValue = "";

So possibly try

oNode.rawValue = null; 

Niall