读取下拉列表中所选的值,而不读取第一个值

Read selected values of a dropdownlist without first value

本文关键字:读取 第一个 下拉列表      更新时间:2023-09-26

在我的应用程序中,我们有许多下拉列表。我只想阅读那些具有选定值的下拉列表。我可以通过以下代码获得这些值。但是下面的代码返回dropdownlist的第一个值,也就是"Select One"。我不想要这个值。有什么办法可以让我摆脱这个价值观吗。

这是我的密码。

@@@@@@@@@@

<div>
    <ul class="nav nav-tabs nav-stacked" data-bind="foreach:fileHeaders">
        <li><div>               
                <select data-bind="options:$parent.parentDDL, optionsText: 'text', optionsValue: 'id',value : parentTypeName, optionsCaption: 'Select Type...'"></select>
               <span class="childselect" data-bind="visible:showChildDDL"><select id="selChildDDL" data-bind="options:childDDL,  value: childSelect" ></select></span> 
            </div>
        </li>
    </ul>
</div>

self.saveImportClicked = function (temp) {
     var ids2 = $(".selChildDDL > option:selected")
                  .map(function (n, i) { return ($(i)[0].innerHTML); })
                  .toArray().join(",");
};

尝试

var ids2 = $(".selChildDDL > option:selected").not(':first-child').map(function (n, i) { return ($(i)[0].innerHTML);  }).toArray().join(",");

返回值

var ids2 = $(".selChildDDL > option:selected").not(':first-child').map(function (n, i) { return $(this).val();  }).toArray().join(",");