使用event.Change从数组获取值 [英] Get values from Array with event.Change

查看:186
本文介绍了使用event.Change从数组获取值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

所以我正在处理以下问题.

So I'm dealing with the following.

我正在创建PDF,并让用户填写字段. 字段之一是列表.选择后,其他字段将填充合适的内容.

I'm creating a PDF and let the user fill in fields. One of the fields is a list. Upon selection other fields are filled with fitting content.

此内容存储在数组中.

这就是我所做的:

var company = ["comapny name", "street", "Postcode", "City", "Country"];
var company1 = ["comapny name1", "street1", "Postcode1", "City1", "Country1"];
if (!event.willCommit){ 
    if (listCompany.value == "comapny name"){
        this.getField("fldStreet").value = company[2];
    }
    if (listCompany.value == "comapny name1"){
        this.getField("fldStreet").value = company1[2];
    }
}

以上部分没有给出错误,但给了我上一步"的内容.
PDF加载,然后填充字段.更改列表后,字段将不会更改其内容.仅在第二次单击之后.

The above part does not give an error but gives me the "previous" content.
The PDF loads and then fields are filled. Upon change of list the fields won't change their content. Only after the second click.

所以我发现了以下内容: event.changeEx;

So I found the following: event.changeEx;

简单尝试后,效果很好:

After a simple try it works great:

var company = ["comapny name", "street", "Postcode", "City", "Country"];
var company1 = ["comapny name1", "street1", "Postcode1", "City1", "Country1"];
if (!event.willCommit){ 
    if (listCompany.value == "comapny name"){
        this.getField("fldStreet").value = event.changeEx;
    }
    if (listCompany.value == "comapny name1"){
        this.getField("fldStreet").value = event.changeEx;
    }
}

这给了我所选项目的价值.但是我现在遇到的问题是如何根据选择从数组中选择其他字段.

This gives me the value of the selected item. But the problem I'm having now is how to select the other fields from my array based upon the selection.

推荐答案

在大量搜索后将其修复.

Fixed it after a lot of googling.

event.changeEx适用于组合框并采用更改的值. 这意味着选择更改后会立即进行更新.

The event.changeEx works on comboboxes and takes the value of the change. This means that this is updated as soon as the selection changes.

这可能会导致以下结果:

Which can result in the following:

var company = ["comapny name", "street", "Postcode", "City", "Country"];
var company1 = ["comapny name1", "street1", "Postcode1", "City1", "Country1"];
if (!event.willCommit){ 
    if (event.changeEx == "comapny name"){
        this.getField("fldStreet").value = company[1];
    }
    if (event.changeEx == "comapny name1"){
        this.getField("fldStreet").value = company1[1];
    }
}

如果event.changeEx值等于公司名称,则可以读取该数组.

If the event.changeEx value equals the company name the array can be read.

下一步是创建某种循环,因为我不想对每个公司都这样做:-)

Next step is to create some sort of loop because I'm not gonna do this for every company :-)

这篇关于使用event.Change从数组获取值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆