listbox添加js事件
<asp:ListBox ID="ListBox1" runat="server" Height="268px" Width="194px" onchange="AddOne('ListBox1','ListBox2')"></asp:ListBox>
这个listbox后台绑定的source,单击某个元素的时候触发AddOne()这个客户端js事件,好像执行不起来。。。。
有什么其他办法能让这个listbox的元素被鼠标左键单击后触发js事件么? --------------------编程问答-------------------- 哦 是我自己弄错了 各位哥不用解答了 谢谢
真不好意思 --------------------编程问答-------------------- listBox1.Attributes.Add( "onclick ", "Display(); ");
var listBox = document.getElementById( "ListBox1 ");
alert(listBox.options[listBox.selectedIndex].value);
--------------------编程问答-------------------- jiefen --------------------编程问答-------------------- 页面加载的时候 绑定下这个对象的onclick不就好了 ? --------------------编程问答-------------------- --------------------编程问答-------------------- 是你的AddOne代码写错了。
js代码只能使用客户端的DOM对象 --------------------编程问答--------------------
AddOne()思路上没错,传2个控件名,js用getElementById获取对象
是我不小心在AddOne()中多打了一个"}"...
补充:.NET技术 , ASP.NET