如何修复用户只能在运行时选中10个复选框 [英] How to fix a user can select only 10 check boxs at run time
本文介绍了如何修复用户只能在运行时选中10个复选框的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我的页面中有一个复选框列表....我需要限制用户只能在10个复选框内选择...我使用复选框作为HTML的输入类型....我该怎么办?那????
I have a check box list in my page....I need to limit the user can select only within 10 checkboxes...I had use the check boxes as input type of HTML.... How can i do that????
推荐答案
OnChecked - 增加一个计数器变量
OnUnChecked - 递减计数器变量
一旦你有这个...
在支票上你可以验证计数,如果计数> 10取消选中它并向用户显示一条消息。
如果您需要更多提示,请分享一些示例代码
OnChecked -- increment a counter variable
OnUnChecked -- decrement a counter variable
Once you have this in place ..
On check you can validate the count and if count > 10 uncheck it and show a message to the user.
Please share some sample code if you need more hints
write复选框选择更改事件
和
当checkbox.checked为true时递增count变量
并在checkbox.checked为false时递减count变量。
希望这有助于......!
write checkbox selection changed event
and
increment the count variable when checkbox.checked is true
and decrement the count variable when checkbox.checked is false.
Hope this helps...!
从代码后面调用函数如下:
Call function from code behind like this:
string script = "<SCRIPT LANGUAGE='JavaScript'> ";
script += "counter()";
script += "</SCRIPT>";
Page.RegisterClientScriptBlock("ClientScript", script);
In你的页面的头部添加这样的功能:
In your page''s head section add function like this:
<script type="text/javascript">
function counter()
{
//increment or decrement variable
}
</script>
根据您的需要努力增加和减少。
Put some efforts to increment and decrement according to your needs.
这篇关于如何修复用户只能在运行时选中10个复选框的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文