【发布时间】:2018-07-19 12:38:38
【问题描述】:
我需要在子列表字段中实现依赖下拉菜单。
我已经使用form.addSubList(); 创建了子列表
在套件中并在子列表中添加了两个选择字段。使用 setScript() 调用客户端脚本进行一些验证和插入值。
这两个选择字段应该是相关的。例如,如果我分别有两个主要下拉列表和次要下拉选择字段,在主要下拉列表中可能是旅行,国家/地区,第二个选择字段应根据第一个选项的选择动态填充。如果我选择了旅行,那么第二个选择字段应该显示下拉值:Travel-Domestiv、Travel- International,如果选择了国家,它应该是阿根廷、比利时、印度。
为了实现这一点,我在字段更改时实施,使用 nlapiInsertLineItemOption 和 nlapiRemovetLineItemOption 我更新了值。但是当下一行更新时,第二次选择会覆盖这些值。请帮助我如何存储值或 id 它可以根据选择来禁用/隐藏子列表字段中的下拉列表,或者可以通过 psot 采购来实现。
代码 sn-p:
if(primary_selected == '1')//primary_selected dropdown:Travel and Country
{
nlapiRemoveLineItemOption('custpage_other_cost_sublist_plan', 'custpage_secondary_plan_items'); //remove all existing select options
nlapiInsertLineItemOption('custpage_other_cost_sublist_plan', 'custpage_secondary_plan_items', '', '',true);
nlapiInsertLineItemOption('custpage_other_cost_sublist_plan', 'custpage_secondary_plan_items', '1', 'Domestic',false);
nlapiInsertLineItemOption('custpage_other_cost_sublist_plan', 'custpage_secondary_plan_items', '2', 'International',false);
nlapiInsertLineItemOption('custpage_other_cost_sublist_plan', 'custpage_secondary_plan_items', '3', 'Others',false);
}
else
{
if(primary_selected == '3')
{
nlapiRemoveLineItemOption('custpage_other_cost_sublist_plan', 'custpage_secondary_plan_items'); //remove all existing select options
nlapiInsertLineItemOption('custpage_other_cost_sublist_plan', 'custpage_secondary_plan_items', '', '',true);
nlapiInsertLineItemOption('custpage_other_cost_sublist_plan', 'custpage_secondary_plan_items', '4', 'Argentina',false);
nlapiInsertLineItemOption('custpage_other_cost_sublist_plan', 'custpage_secondary_plan_items', '5', 'Belgium',false);
//nlapiInsertLineItemOption('custpage_other_cost_sublist_plan', 'custpage_secondary_plan_items', '6', 'India');
}
}
【问题讨论】: