简体   繁体   English

如何从LiveCycle的下拉列表中的一个子窗体中的数据填充文本字段到另一个子窗体

[英]How to populate text fields with data in one subform to another subform from a dropdown list in LiveCycle

I don't know much about JavaScript but feel that this should be fairly easy. 我对JavaScript不太了解,但是觉得这应该很容易。 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) form1.CapExForm.Subform1.Table1.HeaderRow [0] .DropDownList1 :: click-(JavaScript,客户端)

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) form1.Subform3.ApprovalSubForm.Table3.Row2.RequestorName :: click-(JavaScript,客户端)

I had previously done this in a PDF form but needed the form to flow and add rows so moved to LiveCycle. 我以前是用PDF表单完成此操作的,但需要该表单进行流动并添加行,以便移至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: 下面是我在Adobe PDF表单中使用的脚本(“软件> $ 1,000,000”来自下拉列表,下面的所有信息将是我要根据该选择填充的文本字段),以帮助阐明我的尝试:

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";
}

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. Designer的javascript与Acrobat的javascript不同。 Here is a good reference for that: Livecycle Scripting Reference . 这是一个很好的参考: Livecycle Scripting Reference

And here is a more comprehensive list of the properties available through javascript in Designer. 这是Designer中可通过javascript使用的属性更全面列表

First, put it in the change event for the dropdown. 首先,将其放入下拉菜单的change事件中。 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. 如果将其放在click事件中,即使他们未进行更改,只要他们单击该字段,该事件就会运行。

In that event, put javascript like this: 在这种情况下,将javascript如下所示:

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. 在此,xfa.event.newText指的是更改后下拉菜单的值。 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. .newText属性仅在更改事件期间可用,并且您想使用该属性,因为在更改事件期间,该字段的rawValue等于原始值。 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.) 剩下的时间中,您可能想使用.rawValue来访问字段的值,这就是为什么我们使用它来设置其他字段的值的原因(因为它们不是触发变更事件的字段)。

A SOM expression is a reference to a field. SOM表达式是对字段的引用。 Example - based on what you pasted above, the SOM expression for the dropdown is form1.CapExForm.Subform1.Table1.HeaderRow[0].DropDownList1. 示例-根据您上面粘贴的内容,下拉菜单的SOM表达式为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; 最简单的方法是转到脚本编辑器,按住Ctrl和shift键,然后单击该字段。 this inserts its SOM expression into the script window. 这会将其SOM表达式插入脚本窗口。

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. 在这种情况下,“ this”将指向您要更改其值的字段,因为脚本将在该字段的calculate事件中运行。 The calculate event fires whenever something changes in one of the fields that are referenced in the calculate script. 每当在calculate脚本中引用的字段之一发生任何更改时,都会触发calculate事件。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何将下拉数据从一个下拉列表填充到另一个下拉列表? - How to populate dropdown data from one dropdown to another dropdown? 如何在javascript中的另一个下拉列表中填充排除任何一个选项的下拉列表? - How can I populate a dropdown list excluding any one option from another dropdown list in javascript? 如何通过从另一个下拉列表中选择值来填充下拉列表? - How to populate a dropdown list by selecting the value from another dropdown list? 从另一个下拉列表中填充下拉列表 - Populate dropdown list from another dropdown list 从下拉菜单选择中填充文本字段 - Populate Text Fields from Dropdown menu Selections 根据另一个下拉列表填充一个下拉列表 - Populate one dropdown list based on another dropdown list 如何将值从一个下拉列表存储到另一个下拉列表 - How to store value from one dropdown list to another dropdown list 从另一个下拉列表中选择一个值后填充下拉列表 - Populate dropdown list upon selecting a value from another dropdown list 如何通过从另一个下拉列表中选择值来填充下拉列表? - How can i populate a dropdown list by selecting the value from another dropdown list? 如何通过从另一个下拉列表中选择值来填充下拉列表 - How can i populate a dropdown list by selecting the value from another dropdown list
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM