简体   繁体   English

如何在NetSuite中动态更改下拉菜单

[英]How to make dynamically changing drop-down menu's in NetSuite

Suppose there are two drop down menu's in a page and I want to change the second drop-down menu based on the selection of the first one. 假设页面中有两个下拉菜单,我想根据第一个下拉菜单的选择来更改第二个下拉菜单。

For Example. 例如。

The first drop-down menu has a list of record types. 第一个下拉菜单包含记录类型列表。 If I select the customer record type, the second drop-down menu should automatically change to a list of customers. 如果我选择customer记录类型,则第二个下拉菜单应自动更改为客户列表。 Same with script deployments etc. script deployments等相同。

Not only the drop down menu's but also any dynamic action in a suitelet page. 不仅是下拉菜单,而且套件页面中的任何动态操作。

What I've tried 我尝试过的

I've created a suitelet with a drop-down menu. 我已经创建了一个带有下拉菜单的小套房。 When the form is submitted the script takes the value and populates the menu. 提交表单后,脚本将获取值并填充菜单。

var start = function(request, response) {
    if(request.getMethod() == 'GET') {
        var form1 = nlapiCreateForm('New Form 1');
        var select1 = form1.addField('custpage_select1', 'select', 'Select A record Type', '-123');
        form1.addSubmitButton('submit');
        response.writePage(form1);
    }
    else {
        var id = request.getParameter('custpage_select1');
        var form2 = nlapiCreateForm('New Form 2');
        var select2 = form2.addField('custpage_select2', 'select', 'Select A record Value', id);
        response.writePage(form2);
    }
}

What I need is this whole thing in a single form. 我需要的是整件事的单一形式。 Something like, 就像是,

var start = function(request, response)  {
    var form1 = nlapiCreateForm('New Form 1');
    var select1 = form1.addField('custpage_select1', 'select', 'Select A record Type', '-123');
    var select2 = form1.addField('custpage_select2', 'select', 'Select A record Type', XXXXX);//the source of the 1st select field
    form1.addSubmitButton('submit');
    response.writePage(form1);
}

Javascript code JavaScript代码

 function configureDropDownLists(ddl1,ddl2) { var Customer = new Array('Customer1', 'Customer2', 'Customer3'); var Script = new Array('Script1', 'Script2', 'Script3'); var etc = new Array('etc1', 'etc2', 'etc3'); switch (ddl1.value) { case 'Customer': ddl2.options.length = 0; for (i = 0; i < Customer.length; i++) { createOption(ddl2, Customer[i], Customer[i]); } break; case 'Script': ddl2.options.length = 0; for (i = 0; i < Script.length; i++) { createOption(ddl2, Script[i], Script[i]); } break; case 'etc': ddl2.options.length = 0; for (i = 0; i < etc.length; i++) { createOption(ddl2, etc[i], etc[i]); } break; default: ddl2.options.length = 0; break; } } function createOption(ddl, text, value) { var opt = document.createElement('option'); opt.value = value; opt.text = text; ddl.options.add(opt); } 
 <select id="ddl" onchange="configureDropDownLists(this,document.getElementById('ddl2'))"> <option value=""></option> <option value="Customer">Customer</option> <option value="Script">Script</option> <option value="etc">etc</option> </select> <select id="ddl2"> </select> 

Hope this helps 希望这可以帮助

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM