datagrid 和 checkbox在线等,分不够再加 我做了一个datagrid,并且其中有个模板列checkbox要求用javascript在客户端,实现:当选中checkbox时,该行的颜色改变请各位大虾,看清楚我的要求再做分不够可再加 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 通过判断checkbox的id值 知道在table的哪行,然后通过 table.rows[第几行].style.backgroundColor 改变行颜色就行了 //得到checkbox所在的行,obj就是checkboxvar objTR = obj.parentElement;while (objTR.tagName != "TR") objTR = objTR.parentElement;//改变该行的颜色if (obj.checked){ objTR.style.backgroundColor = "选中的颜色";}else{ objTR.style.backgroundColor = "取消选中的颜色";} <script language="javascript">function CheckBox_Click(p_this){ if (p_this.checked == true) { p_this.parentElement.parentElement.bgColor = "highlight"; p_this.parentElement.parentElement.style.color = "white"; } else { p_this.parentElement.parentElement.bgColor = "white"; p_this.parentElement.parentElement.style.color = "black"; }}</script><table id="DataGrid" width="100%" bordercolor="#FF0000" border="1" cellspacing="0"> <tr> <td width="20"> <input type="checkbox" onclick="CheckBox_Click(this);"> </td> <td> One</td> </tr> <tr> <td width="20"> <input type="checkbox" onclick="CheckBox_Click(this);"> </td> <td> Two</td> </tr> <tr> <td width="20"> <input type="checkbox" onclick="CheckBox_Click(this);"> </td> <td> Three</td> </tr></table> 动态绑定数据与javascript联合实现选中变色,已经实现在http://community.csdn.net/Expert/topic/4218/4218792.xml?temp=.1076166 ASP.NET中从数据库里读出word文件,修改后重新保存进数据库,应该怎么做? 关于DLL文件的问题 关于论坛模版问题 写入数据到数据库 sql数据库两表查询问题 updatePanel問題 .net中一个页面如何实现放置两个滑动门? 创建控件的时候是选择自定义服务器控件还是选择用户控件?怎么选择? 请教数据汇总的问题 关于聊天室,留言板问题,有劳高手指点 大家帮忙来看看?? 竟有这种事:Treeview在服务器端竖向显示正常,但在客户端却横向排列,怎么回事啊?
table.rows[第几行].style.backgroundColor 改变行颜色就行了
var objTR = obj.parentElement;
while (objTR.tagName != "TR")
objTR = objTR.parentElement;//改变该行的颜色
if (obj.checked)
{
objTR.style.backgroundColor = "选中的颜色";
}
else
{
objTR.style.backgroundColor = "取消选中的颜色";
}
function CheckBox_Click(p_this)
{
if (p_this.checked == true)
{
p_this.parentElement.parentElement.bgColor = "highlight";
p_this.parentElement.parentElement.style.color = "white";
}
else
{
p_this.parentElement.parentElement.bgColor = "white";
p_this.parentElement.parentElement.style.color = "black";
}
}
</script><table id="DataGrid" width="100%" bordercolor="#FF0000" border="1" cellspacing="0">
<tr>
<td width="20">
<input type="checkbox" onclick="CheckBox_Click(this);">
</td>
<td> One</td>
</tr>
<tr>
<td width="20">
<input type="checkbox" onclick="CheckBox_Click(this);">
</td>
<td> Two</td>
</tr>
<tr>
<td width="20">
<input type="checkbox" onclick="CheckBox_Click(this);">
</td>
<td> Three</td>
</tr>
</table>
http://community.csdn.net/Expert/topic/4218/4218792.xml?temp=.1076166