如何将函数应用于下拉列表

how apply function to Dropdown?

本文关键字:应用于 下拉列表 函数      更新时间:2023-09-26

如何使用函数 ToggleDropDown() for dropdown asp tag:::?
我想在"全部"标记之间输入文本当用户从下拉列表中选择时

function ToggleDropDown(targetId, targetSelcteTextId) {
        var e = document.getElementById("" + targetId + "");
        var strUser = e.options[e.selectedIndex].text;
        $("#" + targetSelcteTextId + "").text(strUser);
    }

我的代码..>>

<span class="ui-btn-inner">
    <span class="ui-btn-text" id="ddpChannelCatgSELECTED" onchange="ToggleDorpDown('ddpChannelCatg', 'ddpChannelCatgSELECTED')">
      <span>All</span>
    </span>
 <span class="ui-icon ui-icon-arrow-d ui-icon-shadow"></span>


<asp:DropDownList runat="server" TabIndex="508" Width="100%" ID="ddpChannelCatg" />

尝试:

$(document).ready(function(){
    $("#<%= ddpChannelCatg.ClientID %>").change(function(){
        ToggleDorpDown(this.id, 'ddpChannelCatgSELECTED');
    });
});

试试这个

function ToggleDropDown(targetId, targetSelcteTextId) {
    $('#' + targetSelcteTextId).text($('#' + targetId).find('option:selected').html());
};