These forums are now Read Only. If you have an Acrobat question, ask questions and get help from one of our experts.

Change Event : Change Drop Down Value based on Numeric Field

Gattaca714
Registered: Dec 16 2009
Posts: 25

This is my code:
 
---------------------------------------------------------------------------------
IFS.#subform[10].fldEnvelopeOrder1[6]::change - (JavaScript, client)
  
if(this.rawValue > 1){
 
IFS.#subform[10].fldEnvelopeOrderColor[0] = "Yellow";
 
}
 
else if(this.rawValue < 1){
 
IFS.#subform[10].fldEnvelopeOrderColor[0] = "";
 
}
 
-------------------------------------------------------------------------------
 
My goal is the following:
 
The default have of fldEnvelopeOrder1[6] is 0. If the field fldEnvelopeOrder1[6] changes to a value greater than 1 then the Drop down field fldEnvelopeOrderColor[0]should equal "Yellow". Otherwise "".
 
Any leads with figuring this out would be appreciated. It might be that the trigger should maybe be "Enter" but I'm not sure.
 
Thanks.

My Product Information:
LiveCycle Designer, Windows
thomp
Expert
Registered: Feb 15 2006
Posts: 4411
The change event is called each time the user presses a key when the field has the focus. It's basically a keystroke event. This event is not called if the field value is modified in some other way. For example by importing data or from a script. If you want the dropdown field modified only under these conditions then the change event is a good choice.

The "this.rawValue" property does not show the changed value. The newly entered data is in the event object.
For example:

if(Number(xfa.event.newText) > 1)
{
...
}

Alternatively you could use the validate event, which is called when data is committed to the field. But you'll need to return a true false value, because that's what Acrobat expects from the validate event. Unless you need to do real validation just put "true;" as the last line of the script.


Thom Parker
The source for PDF Scripting Info
www.pdfscripting.com
Very Important - How to Debug Your Script

Gattaca714
Registered: Dec 16 2009
Posts: 25
If I understand you correctly:

if(Number(xfa.event.newText) > 1)
{
fldEnvelopeOrderColor[0].event.value = "Yellow";
}
else if(Number(xfa.event.newText) < 1)
{
fldEnvelopeOrderColor[0].event.value = "";
}

xfa.event.newtext will show the new data in the number field so I changed that. And also the true statement needs an event.value to tell it what the new value should be. It currently doesn't have a default value.

I think I'm getting closer but I'm not there yet.

Thanks.
thomp
Expert
Registered: Feb 15 2006
Posts: 4411
The xfa.event.newText property contains full text of the data the user is entering into the number field.

To change the value of your dropdown use the "rawValue" property. Like this;

if(Number(xfa.event.newText) > 1)
{
fldEnvelopeOrderColor.rawValue = "Yellow";
}
else if(Number(xfa.event.newText) < 1)
{
fldEnvelopeOrderColor.rawValue = "";
}

For a LiveCycle JavaScript, the instance index of the form element cannot be used in the SOM path. If you have more than one instance of the same element you'll need to access it using the resolveNode function.

Thom Parker
The source for PDF Scripting Info
www.pdfscripting.com
Very Important - How to Debug Your Script