无法使用javascript获取复选框列表 [英] Not able to get the checkboxlist using javascript

查看:109
本文介绍了无法使用javascript获取复选框列表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在将javascript用于我的应用程序中的一个ascx控件.

ascx控件在面板内具有复选框列表.我有一个javascript函数来处理复选框列表项的onclick.

我正在尝试将复选框列表作为

var checkBoxList = document.getElementById(<%= CheckBoxList1.ClientID%>");

->它给复选框列表为空;也尝试过,

var checkBoxList = document.getElementById("CheckBoxList1");

如果该值也为null.

I am using javascript for one of the ascx controls in my application.

The ascx controls have checkbox lists inside a panel. I have a javascript function to handle the onclick of checkboxlist items.

I am trying to get the checkbox list as

var checkBoxList = document.getElementById("<%= CheckBoxList1.ClientID %>");

--> it gives checkbox list as null; Also trying with,

var checkBoxList = document.getElementById("CheckBoxList1");

hen also the value is null.

How can I get the checkboxlist item here?

推荐答案



尝试在运行时使用scriptmanager注册您的javascript函数.


try to register your javascript function at runtime using scriptmanager.


如果您可以使用jQuery,则可以尝试使用jQuery选择器选择复选框.这样会更容易并且可以进行很多更改.

If you can use jQuery you can try selecting the checkboxlist using the jQuery Selector. It will be easier and can be altered as much.


(#{元素的运行时ID")

首先,您可以参考此

http://docs.jquery.com/Tutorials:Getting_Started_with_jQuery [ http://api.jquery.com/category/selectors/ [
("#{runtime id of the element")

To get started you may refer this

http://docs.jquery.com/Tutorials:Getting_Started_with_jQuery[^]

And for jQuery selectors, you may refer this

http://api.jquery.com/category/selectors/[^]

If you dont want to go with jQuery please provide info on what client side event you are trying to get the checkbox list. Is that within the onclick event?


这篇关于无法使用javascript获取复选框列表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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