要实现的问题是这样的(很有难度)有一个信息列表 checkbox 采购编码
0 1
0 1
0 1
0 2
0 2
0 3
button按钮
初始化时checkbox的状态都是未被勾选(0),当点了按钮时开始判断如果采购编码相同,那么相对应的checkbox只有第一个能够被使用也就是(disabled属性)其他都是不可用的也就是以上的界面就变成 checkbox 采购编码
0 1
1 1
1 1
0 2
1 2
0 3
button按钮
就是这么个问题请大家讨论顺便说一下不要问我是哪个大公司,有保密协议不能说的。。
0 1
0 1
0 1
0 2
0 2
0 3
button按钮
初始化时checkbox的状态都是未被勾选(0),当点了按钮时开始判断如果采购编码相同,那么相对应的checkbox只有第一个能够被使用也就是(disabled属性)其他都是不可用的也就是以上的界面就变成 checkbox 采购编码
0 1
1 1
1 1
0 2
1 2
0 3
button按钮
就是这么个问题请大家讨论顺便说一下不要问我是哪个大公司,有保密协议不能说的。。
解决方案 »
- JavaScript如何把用户输入的数字从全角转换为半角
- 40分求 根据国家名称显示当前的js代码 在线等
- 为什么页面无法跳转?
- 调用CSDN的MzTreeView版,怎样实现自动选定某节点?请CSDN或Meizz回答!
- LigerUI表格插件的问题
- 谁能帮我搞定一个含有跳转的JS代码吗?
- 如何打开一个颜色对话框?
- 一个问题。
- 如何让我的JS得到Netscape 的支持?
- 如何点击文字执行js
- HTML控件加上runat=server以后怎么来实现JS代码?
- 怎么获取部分<li>.length (getElementsByTagName?getElementsByName?getElementsById?)
function clk(){
if(this.checked){
for(var i=0;i<tableObject.rows.count-1;i++){
if(tableObject.rows[this.perentElement.perentElement.rowIndex].cell[this.perentElement.cellIndex]==tableObject.row[i].cells[this.perentElement.cellIndex])
tableObject.rows[i].cell[this.perentElement.cellIndex].childNodes[1].disable=true;
}
}
}
循环过程中,先判断checkbox是否己设为disabled。如果是则continue。
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>无标题文档</title>
<script type="text/javascript">
function $(id){
return document.getElementById(id);
}function setButtons(){
var chks=$("tbody1").getElementsByTagName("input");
var chk,td,code,map={};
for(var i=0,len=chks.length;i<len;i++){
chk=chks[i];
td=chk.parentNode;
code=td.parentNode
.cells[1]
.innerHTML;
if(!(code in map)){
map[code]=null;
chk.checked=false;
chk.disabled=false;
}else{
chk.checked=true;
chk.disabled=true;
}
}
}
</script>
</head>
<body>
<table width="448" border="1">
<thead>
<tr>
<td width="66" align="center">选择</td>
<td width="241" align="center">采购编码 </td>
<td width="119" align="center">其他</td>
</tr>
<thead>
<tbody id="tbody1">
<tr>
<td align="center"><input type="checkbox"/></td>
<td>1</td>
<td> </td>
</tr>
<tr>
<td align="center"><input type="checkbox"/></td>
<td>1</td>
<td> </td>
</tr>
<tr>
<td align="center"><input type="checkbox"/></td>
<td>1</td>
<td> </td>
</tr>
<tr>
<td align="center"><input type="checkbox"/></td>
<td>2</td>
<td> </td>
</tr>
<tr>
<td align="center"><input type="checkbox"/></td>
<td>2</td>
<td> </td>
</tr>
<tr>
<td align="center"><input type="checkbox"/></td>
<td>3</td>
<td> </td>
</tr>
</tbody>
<tfoot>
<tr>
<td colSpan="3">
<input type="button" value="设置" onclick="setButtons()"/>
</td>
</tr>
</tfoot>
</table>
</body>
</html>