Javascript + 从选择框中打印值

标签 javascript asp.net vb.net

我有一个名为“ToLB”的选择框,它从另一个选择框中获取值项。我需要从“ToLB”中提取这些选定的值并将其打印在标签上,这就是我的做法,但显然它不起作用,因为没有错误消息,但没有任何内容打印到标签上,请提供建议,谢谢! :

选择框:

<select multiple size="8" name="ToLB" style="width: 135px" onblur="javascript:dropValue6(this)">
</select>

标签:

QMType: <asp:Label ID="destinationQualMemType" runat="server" ></asp:Label >  

Javascript函数:

function dropValue6(source) {
    while (source.selectedIndex != -1)
    {
        if (source.selectedIndex != 0) arSelected.push(source.options[source.selectedIndex].value);
        source.options[source.selectedIndex].selected = false;

        var i;
        for (i = 0; i < arSelected; i++) {

            document.getElementById('<%= destinationSpendingType.ClientID %>').innerHTML =
+ "\n" + document.getElementById('<%= destinationSpendingType.ClientID %>').innerHTML = arSelected[i].value;
        }
    }

         } 

最佳答案

您可以查看标记为 //*** 的行

function dropValue6(source) {
    var arSelected = [];   // ***
    while (source.selectedIndex != -1)
    {
        if (source.selectedIndex != 0) arSelected.push(source.options[source.selectedIndex].value);
        source.options[source.selectedIndex].selected = false;

        var i;
        for (i = 0; i < arSelected.length; i++) {  // ***                
            document.getElementById('<%= destinationSpendingType.ClientID %>').innerHTML = arSelected[i];  // ***
        }
    }    
} 

关于Javascript + 从选择框中打印值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7594796/

相关文章:

.net - 如何从进程名称中获取应用程序名称?

.net - 通过身份验证自动从网站下载图片

vb.net - 在 Visual Basic 中绘制节点图

javascript - 如何找到在浏览器中禁用 JavaScript 的用户数量?

javascript - 单击上一个文本字段时创建一个新的文本字段

javascript - 使用 <select/> 下拉列表值过滤列表结果

C#:GridView、逐行操作

c# - 处理在辅助线程过程中发生的未处理错误

javascript - 尽管 html 表中有数据,但仍显示 "No data available in table"

c# - 自定义数据验证注释 - ASP.NET MVC2 C#