Expand my Community achievements bar.

Don’t miss the AEM Skill Exchange in SF on Nov 14—hear from industry leaders, learn best practices, and enhance your AEM strategy with practical tips.
SOLVED

Dropdown values in change event not returning current value

Avatar

Level 2

Hi,

I have a dropdown which I am populating using javascript as per Brad's post here http://blogs.4point.com/brad.white/2010/03/populate-a-drop-down-with-a-web-service-in-a-pdf.html .

I have hooked up the change event of this dropdown to show the new selection in a seperate text box as below

//ApplicationForm.Page1.ddlUsers::change - (FormCalc, client)

txtSelected.rawValue = ddlUsers.rawValue

This code is works, but shows the previous (or last) values that was selected in the dropdown but not the current value which was selected by the user. I also tried using selectedIndex instead rawValue on ddlUsers but it has the same behavior. The dropdown's "Commit On" is set to "Select"

Am I missing something here? how do I get the current value that is selected into the dropdown.

Thanks

Shreedhar

1 Accepted Solution

Avatar

Correct answer by
Level 10

Hi Shreedhar,

I haven't looked at the blog, but the most appropriate property to use with the change event is xfa.event.newText instead of .rawValue.

So, as Javascript:

txtSelected.rawValue = xfa.event.newText; 

Hope that helps,

Niall

View solution in original post

7 Replies

Avatar

Correct answer by
Level 10

Hi Shreedhar,

I haven't looked at the blog, but the most appropriate property to use with the change event is xfa.event.newText instead of .rawValue.

So, as Javascript:

txtSelected.rawValue = xfa.event.newText; 

Hope that helps,

Niall

Avatar

Level 2

Thanks Niall,

That works. Also I am getting the text in the dropdown instead of the value assigned. But I can work around that somehow.

Thanks again for pointing this out.

Shreedhar

Avatar

Level 10

Hi Shreedhar,

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

Here I have outlined three ways of accessing the display values and bound values from a dropdown.

The first is where all of the script is in the calculate event of the textfields and not in the dropdown at all.

The second is where the script is in the exit event of the dropdown. This is my preferred option.

The third is where the script is in the change event of the dropdown.

Each option is slightly different to take into account the different objects and events used.

I hope that helps,

Niall

Avatar

Level 2

Wow, I was using some crude method for doing this. I only saw this update now. I am going to update my PDF with option 2.

Out of curiosity, where do you get this knowledge from? do you work at Adobe? either that or my googling skill have deteriorated a lot.

Thanks for all your help.

Shreedhar

Avatar

Level 10

Hi Shreedhar,

No, I am out on my own, but been working with LC Designer for years. Picked up code from blogs, forums, etc. JP Terry's book "Designing LiveCycle Forms" is excellent.

Here are some resources that you might find helpful:

http://www.adobe.com/go/learn_lc_scriptingBasics

http://www.adobe.com/go/learn_lc_scriptingReference

http://www.adobe.com/go/learn_lc_formCalc

http://www.adobe.com/devnet/livecycle/articles/Adobe_XML_Form_Object_M odel_Refer ence.pdf

http://www.adobe.com/devnet/acrobat/pdfs/lc_migrating_acrobat_xmlform. pdf

And a very handy resource (and while it is for version 6 it is still very good because of the way it is laid out):http://partners.adobe.com/public/developer/en/tips/CalcScripts.pdf

The help file also helps with syntax and LC Designer comes with templates/examples.

Lastly, check out the Developer's Network on http://www.adobe.com/devnet/livecycle/

Good luck,

Niall

Avatar

Level 2

Thanks for sharing Niall.You have saved me a whole lot of time. I hope I will be able to do the same for someone else in need and carry on your legacy.

Regards,

Shree

Avatar

Level 1

Hi Niall!

I know you posted this a while ago, but I'm having the exact same problem as shreedhark.

However, when I click on your link (https://acrobat.com/#d=O1BVeK1eK6lfyUGFFcpEvw),  I can't view the sample

Is there another way to find it?

Kindly

Oscar