Expand my Community achievements bar.

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
Former Community Member

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

Former Community Member

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

Former Community Member

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

Steve

Avatar

Correct answer by
Former Community Member

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

Former Community Member

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!

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] ----