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

Trying to change caption based on dropdown value

Avatar

Level 2

Two elements are involved:

Dropdown list called TransactionType - possible values are "A" "B" or "C"

Checkbox chkVerification

I have created the following javascript for the change event of the dropdownbox TransactionType

form1.#subform[0].TransactionType::change - (JavaScript, client)

if(this.rawValue == "A"){chkVerification.caption.value.text.value = "Verification A"}

else if(this.rawValue == "B"){chkVerification.caption.value.text.value = "Verification B";}

When I check the script syntax it comes up without any errors, but when I change the value in the drop down the caption of the checkbox never changes.

What am I missing here?

By using the app.alert function I think I can see that I need to trigger the script as xfa.event.newText  but the caption isn't changing.

I've also tried this :

form1.resolveNode("chkVerification.caption.value.#text").value = "Verification A";

Is what I'm trying to do even possible?

1 Accepted Solution

Avatar

Correct answer by
Level 10

The form has to be saved as a dynamic PDF form to enable dynamic behaviour including caption changes.

Additionally, I find it much easier to explicitly name pages. It is less problematic. So rather than accessing "form1.#subform[0].DropDownList1" you are accessing "form1.page1.DropDownList1".

// form1.page1.DropDownList1::exit - (JavaScript, client)

var char_ = this.rawValue;

xfa.resolveNode("form1.page1.CheckBox1.caption.value.#text").value = char_;

Steve

View solution in original post

7 Replies

Avatar

Level 10

1) Did you save the form as a dynamic PDF?

2) Put the script on the exit event rather than the change event and use resolveNode

// form1.page1.dd::exit - (JavaScript, client)

var char_ = this.rawValue;

xfa.resolveNode("form1.page1.cb.caption.value.#text").value = "Verfication " + char_;

Steve

Avatar

Level 2

Still not working - again no error messages or complaints from the compiler, the caption simply doesn't change like it is supposed to.

Avatar

Level 10

If you forward the form to stwalker.adobe@gmail.com and I can take a look.

Steve

Avatar

Correct answer by
Level 10

The form has to be saved as a dynamic PDF form to enable dynamic behaviour including caption changes.

Additionally, I find it much easier to explicitly name pages. It is less problematic. So rather than accessing "form1.#subform[0].DropDownList1" you are accessing "form1.page1.DropDownList1".

// form1.page1.DropDownList1::exit - (JavaScript, client)

var char_ = this.rawValue;

xfa.resolveNode("form1.page1.CheckBox1.caption.value.#text").value = char_;

Steve

Avatar

Level 2

I thought it was saved as a dynamic form... when I was working in another form with other features I saved it the same way and things worked correctly.

Does that mean that I can't use the preview PDF tab in live cycle to test the code?

Avatar

Level 10

No. You have two options:

1)  Configure LiveCycle Designer to use dynamic XML form as the default data type, or

Untitled.png

2) Save the form as a dynamic PDF before doing preview.

Steve

Avatar

Level 2

Hi Steve,

Its a bit of an old thread already, but I am facing similar problems to what Albert was facing.

My form is already configured to use 1)dynamic XML form as default data type and 2)Preview as Interactive form.

The techinique I am trying to use is also xfa.resolveNode("form1.page1.cb.caption.value.#text").value = "Abc";

However, it doesn't seem to work. On test, no code is ran after that line, which means that element could be invalid, but I've checked and it seemed ok.

Language used is Javascript and not FormCalc too. Any idea how I can tackle this?

Thanks!