如何在gridview中单击鼠标取消选中radiobutton, [英] How to uncheck radiobutton by mouse click in gridview ,
本文介绍了如何在gridview中单击鼠标取消选中radiobutton,的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我使用gridview作为出勤目的,因为我有31列的radiobutton。点击后选中单选按钮。然后,如果我尝试取消选中相应的radbtn,它将不会取消选中复选框。请帮我代码
提前致谢
解决方案
< span class =code-keyword>< html >
< script 类型 = text / javascript >
var RadioBtn = document.getElementsByName('YourRadioButton');
var booRadio;
var x = 0;
allRadios [x] .onclick = function(){
if(booRadio == this){
this.checked = false;
booRadio = null;
} else {
booRadio = this;
}
};
< / script >
< / html >
在单选按钮上点击这个javascript点击
我没试过,但我希望它有用...告诉我结果是什么
你可能知道设置单选按钮的组名属性如果收音机将不起作用按钮位于数据表示控件中,如GridView
。这是因为GridView
中的单选按钮的行为方式不同。由于GridView
呈现为表元素,因此在运行时它将为每个单选按钮分配不同的名称。因此,您可以选择多行。
这是我几年前写的一篇文章,涵盖了您所面临的问题:使用JavaScript验证在GridView中使用单选按钮 [ ^ ]
Iam using gridview for attendance purpose in that i have radiobutton for 31 columns . after radio button checked by click . then if i try to uncheck the corresponding radbtn it will not uncheck as checkbox. please help me with code
Thanks in advance
解决方案
<html> <script type="text/javascript"> var RadioBtn = document.getElementsByName('YourRadioButton'); var booRadio; var x = 0; allRadios[x].onclick = function() { if(booRadio == this){ this.checked = false; booRadio = null; }else{ booRadio = this; } }; </script> </html>
preform this javascript on radio button click
I didn't Try it but i hope it work...tell me what the result is
As you may know setting the group name attribute of a radio button will not work if the radio button is located within a data representation control like aGridView
. This is because the radio button inside aGridView
behaves differently. Since aGridView
is rendered as a table element, at run time it will assign a different "name" to each radio button. Hence you are able to select multiple rows.
Here's an article I that wrote a few years ago that covers the issue you are facing: Using Radio Button in GridView With JavaScript Validation[^]
这篇关于如何在gridview中单击鼠标取消选中radiobutton,的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文