帮我看看?checkbox DataGrid1__ctl4_chkSelect -这是地方是字母 l 而不是数字 1 , L4%2 !=0 当然永远成立喽 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 这位大哥,不要拿l 当1 用,不一样的<html><head><title>Untitled Document</title><meta http-equiv="Content-Type" content="text/html; charset=gb2312"></head><script language="JAVASCRIPT">function AddRemoveValues(oChk) { bgColor = "FEEEE0";if(oChk.checked){alert("in");}else{var countId= oChk.id.substring(13,15);alert(parseInt(countId));if(parseInt(countId)%2!= 0){alert("nihao");}else{alert("buhao");}}//alert(frmAreaSearch.HdnSelectedValues.value);} </script><body bgcolor="#FFFFFF" text="#000000"><form name="frmAreaSearch" method="post" action="" id="frmAreaSearch"><table class="012" cellspacing="0" rules="all" bordercolor="White" border="1" id="DataGrid1" style="border-color:White;border-width:1px;border-style:solid;width:100%;border-collapse:collapse;"> <tr style="background-color:#BBD9F0;"> <td style="width:4%;">选择</td> </tr> <tr> <td> <input name="DataGrid1:_ct12:chkSelect" id="DataGrid1__ct12_chkSelect" type="checkbox" onclick="AddRemoveValues(this)" value="19" /> </td> </tr> <tr style="background-color:WhiteSmoke;"> <td> <input name="DataGrid1:_ct13:chkSelect" id="DataGrid1__ct13_chkSelect" type="checkbox" onclick="AddRemoveValues(this)" value="18" /> </td> </tr> <tr> <td> <input name="DataGrid1:_ct14:chkSelect" id="DataGrid1__ct14_chkSelect" type="checkbox" onclick="AddRemoveValues(this)" value="17" /> </td> </tr></table></form></body></html> <html><head><title>Untitled Document</title><meta http-equiv="Content-Type" content="text/html; charset=gb2312"></head><script language="JAVASCRIPT">function AddRemoveValues(oChk) { bgColor = "FEEEE0";if(oChk.checked){alert("in");}else{var countId= oChk.id.substring(14,15)+0;alert(countId);if(countId%2!= 0){alert("nihao");}else{alert("buhao");}}//alert(frmAreaSearch.HdnSelectedValues.value);} </script><body bgcolor="#FFFFFF" text="#000000"><form name="frmAreaSearch" method="post" action="" id="frmAreaSearch"><table class="012" cellspacing="0" rules="all" bordercolor="White" border="1" id="DataGrid1" style="border-color:White;border-width:1px;border-style:solid;width:100%;border-collapse:collapse;"> <tr style="background-color:#BBD9F0;"> <td style="width:4%;">选择</td> </tr> <tr> <td> <input name="DataGrid1:_ctl2:chkSelect" id="DataGrid1__ctl2_chkSelect" type="checkbox" onclick="AddRemoveValues(this)" value="19" /> </td> </tr> <tr style="background-color:WhiteSmoke;"> <td> <input name="DataGrid1:_ctl3:chkSelect" id="DataGrid1__ctl3_chkSelect" type="checkbox" onclick="AddRemoveValues(this)" value="18" /> </td> </tr> <tr> <td> <input name="DataGrid1:_ctl4:chkSelect" id="DataGrid1__ctl4_chkSelect" type="checkbox" onclick="AddRemoveValues(this)" value="17" /> </td> </tr></table></form></body></html> 你用 substring 取这个数字时会出错的, 当数字大于10之后就是两位数字了, 所以这里用个正则吧 var countId= oChk.id.match(/_ctl\d+_/g)[0].replace(/[_a-z]/gi, ""); highcharts绘图如何从数据库获取数据信息? 求一个页面悬浮框 关于变量用不用this的区别 如何做一个打开网页的.exe文件 var temp = []; 和 var temp[]; 有什么区别? jsp页面中ueditor关联数据库 ExtJS4.0 动态加载树的问题 如何比较两字符串是否相同? 请问高手如何对表格实现如下操作? 根据下拉框选项顺序自动顺序调用页面展示,难! 导航条问题 我要在提交表单时判断其中的单选项有没有选过,如没有选过则跳出警告窗提醒,这个如何做?
<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
</head>
<script language="JAVASCRIPT">
function AddRemoveValues(oChk) {
bgColor = "FEEEE0";
if(oChk.checked)
{
alert("in");
}
else
{
var countId= oChk.id.substring(13,15);
alert(parseInt(countId));
if(parseInt(countId)%2!= 0)
{
alert("nihao");
}
else
{
alert("buhao");
}}
//alert(frmAreaSearch.HdnSelectedValues.value);
}
</script>
<body bgcolor="#FFFFFF" text="#000000">
<form name="frmAreaSearch" method="post" action="" id="frmAreaSearch">
<table class="012" cellspacing="0" rules="all" bordercolor="White" border="1" id="DataGrid1" style="border-color:White;border-width:1px;border-style:solid;width:100%;border-collapse:collapse;">
<tr style="background-color:#BBD9F0;">
<td style="width:4%;">选择</td>
</tr>
<tr>
<td>
<input name="DataGrid1:_ct12:chkSelect" id="DataGrid1__ct12_chkSelect" type="checkbox" onclick="AddRemoveValues(this)" value="19" />
</td>
</tr>
<tr style="background-color:WhiteSmoke;">
<td>
<input name="DataGrid1:_ct13:chkSelect" id="DataGrid1__ct13_chkSelect" type="checkbox" onclick="AddRemoveValues(this)" value="18" />
</td>
</tr>
<tr>
<td>
<input name="DataGrid1:_ct14:chkSelect" id="DataGrid1__ct14_chkSelect" type="checkbox" onclick="AddRemoveValues(this)" value="17" />
</td>
</tr>
</table></form>
</body>
</html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
</head>
<script language="JAVASCRIPT">
function AddRemoveValues(oChk) {
bgColor = "FEEEE0";
if(oChk.checked)
{
alert("in");
}
else
{
var countId= oChk.id.substring(14,15)+0;
alert(countId);
if(countId%2!= 0)
{
alert("nihao");
}
else
{
alert("buhao");
}}
//alert(frmAreaSearch.HdnSelectedValues.value);
}
</script>
<body bgcolor="#FFFFFF" text="#000000">
<form name="frmAreaSearch" method="post" action="" id="frmAreaSearch">
<table class="012" cellspacing="0" rules="all" bordercolor="White" border="1" id="DataGrid1" style="border-color:White;border-width:1px;border-style:solid;width:100%;border-collapse:collapse;">
<tr style="background-color:#BBD9F0;">
<td style="width:4%;">选择</td>
</tr>
<tr>
<td>
<input name="DataGrid1:_ctl2:chkSelect" id="DataGrid1__ctl2_chkSelect" type="checkbox" onclick="AddRemoveValues(this)" value="19" />
</td>
</tr>
<tr style="background-color:WhiteSmoke;">
<td>
<input name="DataGrid1:_ctl3:chkSelect" id="DataGrid1__ctl3_chkSelect" type="checkbox" onclick="AddRemoveValues(this)" value="18" />
</td>
</tr>
<tr>
<td>
<input name="DataGrid1:_ctl4:chkSelect" id="DataGrid1__ctl4_chkSelect" type="checkbox" onclick="AddRemoveValues(this)" value="17" />
</td>
</tr>
</table></form>
</body>
</html>
var countId= oChk.id.match(/_ctl\d+_/g)[0].replace(/[_a-z]/gi, "");