Retrieve this.rawValue = this.parent.index + 1; for use elsewhere | Community
Skip to main content
New Participant
November 23, 2011
Question

Retrieve this.rawValue = this.parent.index + 1; for use elsewhere

  • November 23, 2011
  • 14 replies
  • 12716 views

I have yet another dumb question.  I have a subform with a field displaying the instance number for that form.  It is in layout:ready

this.rawValue = this.parent.index + 1;

How do I retrieve the value of that field for use elsewhere on the form?  I have tried getting the value as itemno.rawValue but it does not give me the rawValue.

Thanks,
Eagle

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.

14 replies

Niall_O_Donovan
New Participant
November 25, 2011

Work with me! Have a look at the solution and previous examples. It is possible, but you do need to use the tools like the JavaScript Console (Control+J) to work through scipting errors. Niall

Eagle0107Author
New Participant
November 25, 2011

Niall,

Thanks for all the help here.  Drop down 1 works but Drop down 2 stll doews not give me the controls.control.itemNo associated with the selection in Drop Down 1.  I think if these worked the way I wanted them to I could figure out how to get the associated text to display.

Thanks,

Eagle

Niall_O_Donovan
New Participant
November 25, 2011

Here is the form back to you: https://acrobat.com/#d=g25N7cxER7im4QC0Ndp6sA.

The i<=nCount was the problem. I just changed it to i<nCount.

Good luck,

Niall

Eagle0107Author
New Participant
November 25, 2011

Sorry, my brain is fried right now...  Corrected URL: 

http://www.xua-llc.com/dropdownformr1.pdf

Niall_O_Donovan
New Participant
November 25, 2011

Hmmm, the link does not appear to be available.

Eagle0107Author
New Participant
November 25, 2011

OK, here is my form again.  Since I cannot expand & wrap a drop down I need to take a different approach.  This is what I came up with.

Any feedback is welcome.  If this is not the right approach I am open to any ideas.

Thanks again for all the assistance.

http://www.xua-llc.com/dropdownlistr1.pdf

Eagle

Niall_O_Donovan
New Participant
November 25, 2011

Hi,

You can change the height using script, but the dropdown wont wrap the display items. It's just one line per display item.

Have you looked at the JavaScript Console (Control+J) in Acrobat (Preview)? If there is an error in your script it is likely that the error will be reported in the console:

I am sure we can get it working, it can just be a bit difficult to give guidance without the form. Just bear in mind that scripting is case sensitive and that you will need to give as full a relative reference as is required between the object with the script and the referenced object.

Have a look at this post and example about referencing, which might help. http://assure.ly/kUP02y.

I suspect that your script is not too far wrong and that it is just a simple reference issue. Also bear in mind Bruce's advice and the example where the vItem is numeric. You would need to convert it into a string.

Niall

Eagle0107Author
New Participant
November 25, 2011

I am still trying to get my head around this.  If I were a programmer I am sure it would be much easier.  I am going to take a good look at this and see if I can figure it out.  If I can't within the next hour or so I will post my form and see if anyone can assist me.

Thanks for all the feedback I really appreciate it.

Actually, I do have another question though.  Is it possible to change the height of a drop down box dynamically?  Since I cannot make it "expand to fit" could I change the height of the drop down based on the height of another field that does expand to fit and wrap?

Eagle

Niall_O_Donovan
New Participant
November 25, 2011

Hi,

I agree with Bruce and the same approach is in the example above. If an object is ABLE to have a value (eg objects other than buttons, subforms, etc), then you will be able to access that object's value using script.

You are already using the JavaScript Console (to see the nCount), is this showing up any other errors?

In relation to your script, I would just say:

Source image file 2652 not available

Because you are starting the var i from 0, the for should stop when i<nCount.

I would have one line to access the object's rawValue:

var vFld = xfa.resolveNode("Subform3.Subform2.Subform1[" + i + "].ItemNo").rawValue;

Also check the object references. For example you started with "itemno" and this is now "ItemNo".

Again if you share your form or the part of the form giving you trouble, I am sure someone will be able to help out.

Niall

_Bruce_Robertson
New Participant
November 25, 2011

Hi Eagle,

The addItem method takes a string so if ItemNo is a numeric field then you might have to change this.addItem(vItem); to this.addItem(vItem.toString());

I know JavaScript will normally do that for us, but the XFA method calls don't seem to do that.

Also, this sort of code should probably be in the preOpen event.

Regards

Bruce