Reputation: 1
I don't know much about JavaScript but feel that this should be fairly easy. I have a drop down list with several options and the below is under the 'Click' option:
form1.CapExForm.Subform1.Table1.HeaderRow[0].DropDownList1::click - (JavaScript, client)
I would like to type in someone's name populate in a text field that has the header scrip below:
form1.Subform3.ApprovalSubForm.Table3.Row2.RequestorName::click - (JavaScript, client)
I had previously done this in a PDF form but needed the form to flow and add rows so moved to LiveCycle. Below is the script ("Software >$1,000,000" was from the dropdown list and all information below that would be the textfields I'm wanting to populate based off that selection) I had in Adobe PDF form if that helps clarify what I am attempting:
if (event.value=="Software >$1,000,000") {
this.getField("Name").value = "Type Requestor Name";
this.getField("Name_2").value = "Type Dept. Manager";
this.getField("Name_3").value = "Todd Stephenson";
this.getField("Name_4").value = "John Kapchinske";
this.getField("Name_5").value = "N/A";
this.getField("Text2").value = "Approval Reviewed: Hazel Welch";
this.getField("Signature").value = "Must click, sign, and save to add signature";
this.getField("Signature_2").value = "Must click, sign, and save to add signature";
this.getField("Signature_3").value = "Must click, sign, and save to add signature";
this.getField("Signature_4").value = "Must click, sign, and save to add signature";
this.getField("Signature_5").value = "Must click, sign, and save to add signature";
this.getField("Signature1").value = "Must click, sign, and save to add signature";
}
Upvotes: 0
Views: 1969
Reputation: 151
Ok - I'm not sure I understand what you want to do, but I'm giving it my best guess. You want some other fields to populate when you select a value from the dropdown, correct?
The javascript for Designer works differently than that for Acrobat. Here is a good reference for that: Livecycle Scripting Reference.
And here is a more comprehensive list of the properties available through javascript in Designer.
First, put it in the change event for the dropdown. If you put it in the click event it'll run whenever they click on the field, even if they don't make a change.
In that event, put javascript like this:
if (xfa.event.newText == "Software >$1,000,000")
{
field1SOMexpression.rawValue = "Value you want";
field2SOMexpression.rawValue = "Next value you want";
//add the other fields you want to reference here
}
Here, xfa.event.newText refers to the value of the dropdown after the change. The property .newText is only available during a change event, and you want to use that one because during the change event, the rawValue of that field is whatever the original value was. The rest of the time you would want to use .rawValue to access the value of a field, and that's why we are using it to set the value of the other fields (because they aren't the fields that triggered the change event.)
A SOM expression is a reference to a field. Example - based on what you pasted above, the SOM expression for the dropdown is form1.CapExForm.Subform1.Table1.HeaderRow[0].DropDownList1.
Without seeing the form I can't tell you what the expression for the fields you want to set values would be, but there are a couple of ways to get the field expression for each field you want to set. The simplest way is to go to the script editor, hold the control and shift keys, and click on the field; this inserts its SOM expression into the script window.
EDIT: If you want the value to be based on the combo of two fields, then it might be easier to use a calculate script in the field that needs to change.
Put script into the calculate event for the field whose value you want to set, to decide what its value should be based on the values of the two dropdowns.
It should be something like this:
var myValue = "";
var type = form1.CapExForm.Subform1.Table1.HeaderRow[0].DropDownList1.rawValue;
var price = ....(whatever the som expression is).PriceRange.rawValue;
if (type == "Software" && price == "1,000,000")
{
myValue = "Value you want";
}
else if (type == "Something else" && price == "Some other price . .")
{
myValue = "Some other value");
}
this.rawValue = myValue;
In that case, 'this' would refer to the field that you want to change the value on, since the script would be running in that field's calculate event. The calculate event fires whenever something changes in one of the fields that are referenced in the calculate script.
Upvotes: 1