首页 > 解决方案 > 使用jquery动态添加下拉列表值(选项)

问题描述

我有一个下拉列表(Dataspy),只有一个选项,它来自云环境,现在我想动态添加一个选项到我的 DataSpy 下拉列表中(因为我没有访问云数据库的权限),下面是我附上了图像,我在 Chrome 中调试期间收到了来自云的值(在下面的情况下值是100116),我如何使用 jquery 创建一个这样的图像?我一点主意都没有 。帮我解决这个问题。
在此处输入图像描述

下面是我想动态添加新选项(WorkRequest)的代码。

function DropdownChange() {
            //let workrequest = new Option('WorkRequest', '1');
            var x = document.getElementById("ddlServices");
            console.log(x);
            var id = x.options[x.selectedIndex].value;
            console.log(id);
            $('#contenttable').empty();
            $('#contenttable').append('<table id="gridview" class="table table-striped table-bordered dataTable wrap" style="width: 100%"><thead></thead><tbody></tbody></table>');
            document.getElementById("lblHeading").innerText = "<%=Resources.Resource.msg_grid_loading %>"//"Loading...."
            RenderData(id);
        }

标签: jquerydynamicdropdown

解决方案


推荐阅读