检查复选框是否在asp.net的javascript中检查 [英] check checkbox is checked or not in javascript in asp.net
本文介绍了检查复选框是否在asp.net的javascript中检查的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
大家好,我是asp.net的新手并试图学习它,
我创建了一个包含按钮和复选框的简单页面。 />
如何检查复选框是否在asp.net中的javascript中检查
Hi all, I am new to asp.net and trying to learn it,
I have created a simple page including a button and a checkboxes.
how to check checkbox is checked or not in javascript in asp.net
推荐答案
这是简单的javascript获取复选框状态的代码。
This is the simple javascript code to get the status of checkbox.
var chkStatus1 = document.getElementById("chkbutton1");
var chkStatus2 = document.getElementById("chkbutton2");
if (chkStatus1.checked) {
// do your implementation for if part
}
else if(chkStatus2.checked)
{
// do your implementation for else if part for checkbox2
}
else if(chkStatus2.checked && chkStatus2.checked)
{
// do your implementation when two chechbox status is checked.
}
else
{
// do your implementation for else part.
}
你可以这样做,
Hi,
You can do it like this,
<script>
function checkcheckbox()
{
//say for example you have checkbox with id="chk"
var value = document.getElementById("<%= chk.ClientID %>").checked;
// now value will have true or false. If true that means checkbox is checked and if value is false, that means checkbox is unchecked.
}
</script>
希望它可以帮到你。
Hope it helps you.
<script type="text/javascript">
var hide1 = true;
function hideColumn1(tableId, colIndex) {
var table = document.getElementById(tableId);
if (table != null) {
for (i = 0; i < table.rows.length; i++) {
if (hide1)
table.rows[i].cells[colIndex - 1].style.display = 'none';
else
table.rows[i].cells[colIndex - 1].style.display = '';
}
hide1 = !hide1;
}
</script>
<asp:repeater id="rpt" runat="server" >
<headertemplate>
<table id="myTable" >
<tr>
<th >
</th>
<th >
</th>
.
.
.
</tr>
</table></headertemplate></asp:repeater>
<input id="Checkbox1" type="checkbox" önclick="hideColumn1('myTable', 1)" runat="server" checked="checked" />
<input id="Checkbox1" type="checkbox" önclick="hideColumn1('myTable', 2)" runat="server" checked="checked" />
<input id="Checkbox1" type="checkbox" önclick="hideColumn1('myTable', 3)" runat="server" checked="checked" />
.
.
.
这篇关于检查复选框是否在asp.net的javascript中检查的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文