用JAVASCRIPT列出 [英] LIST WITH JAVASCRIPT

查看:66
本文介绍了用JAVASCRIPT列出的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

< asp:ListBox ID ="ListBox1" runat =服务器" SelectionMode ="Multiple" Width ="100px">
< asp:ListItem Text ="Select" Value =-1"/>
< asp:ListItem值="1"文本="Text1"/>
< asp:ListItem Value ="2" Text ="Text2"/>
< asp:ListItem Value ="3" Text ="Text3"/>
< asp:ListItem Value ="4" Text ="Text4"/>
< asp:ListItem Value ="5" Text ="Text5"/>

< input id ="TestButton" type ="button" value ="Test"/>

< asp:标签ID ="TestLabel" runat =服务器" Text =">

< script type ="text/javascript">
$(function(){
$(''#TestButton'').click(function(){
var commaSeparated = $(''#<%= ListBox1.ClientID%>选项:已选择'')
.not(''option [value = \''-1 \'']'').map(function(){
返回this.innerHTML;
}).get().join('','');

$(''#<%= TestLabel.ClientID%>'').html(commaSeparated);
});
});
</script>

</form>

<asp:ListBox ID="ListBox1" runat="server" SelectionMode="Multiple" Width="100px">
<asp:ListItem Text="Select" Value="-1" />
<asp:ListItem Value="1" Text="Text1" />
<asp:ListItem Value="2" Text="Text2" />
<asp:ListItem Value="3" Text="Text3" />
<asp:ListItem Value="4" Text="Text4" />
<asp:ListItem Value="5" Text="Text5" />

<input id="TestButton" type="button" value="Test" />

<asp:Label ID="TestLabel" runat="server" Text="">

<script type="text/javascript">
$(function () {
$(''#TestButton'').click(function () {
var commaSeparated = $(''#<%= ListBox1.ClientID %> option:selected'')
.not(''option[value=\''-1\'']'').map(function () {
return this.innerHTML;
}).get().join('','');

$(''#<%= TestLabel.ClientID %>'').html(commaSeparated);
});
});
</script>

</form>

推荐答案

(function(){
(function () {


(``#TestButton'') .click(function(){
var commaSeparated =
(''#TestButton'').click(function () {
var commaSeparated =


(``#<%= ListBox1.ClientID%>选项:已选择'')
.not(''option [value = \''-1 \'']'').map(function(){
返回this.innerHTML;
}).get().join('','');

(''#<%= ListBox1.ClientID %> option:selected'')
.not(''option[value=\''-1\'']'').map(function () {
return this.innerHTML;
}).get().join('','');


这篇关于用JAVASCRIPT列出的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆