题目是这样的:
现在在画面上有一个list表,表里有N条数据,其中有一列是显示番号,还有一列是checkbox框。当点击提交按钮的时候,check相同的番号的checkbox框是否状态一样,如果不一样则报错。例如
checkbox        Number
  true            1
  true            1
  false           1
  true            2
  true            2
   .              .
   .              .
   .              .
   .              .
   .              .
相同的番号 但是checkbox的状态不同都是true或者(都是false是不报错 只有不同的时候报错)

解决方案 »

  1.   

    L@_@K<!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>
      <title> new document </title>
      <meta name="generator" content="editplus" />
      <meta name="author" content="" />
      <meta name="keywords" content="" />
      <meta name="description" content="" />
     </head> <body>
    <table id="tbeTest">
    <tr>
    <th>CheckBox</th>
    <th>Number</th>
    </tr>
    <tr>
    <td><input type="checkbox" checked /></td>
    <td>1</td>
    </tr>
    <tr>
    <td><input type="checkbox" checked /></td>
    <td>1</td>
    </tr>
    <tr>
    <td><input type="checkbox" /></td>
    <td>1</td>
    </tr>
    <tr>
    <td><input type="checkbox" checked /></td>
    <td>2</td>
    </tr>
    <tr>
    <td><input type="checkbox" checked /></td>
    <td>2</td>
    </tr>
    <tr>
    <td><input type="checkbox" checked /></td>
    <td>3</td>
    </tr>
    <tr>
    <td><input type="checkbox" checked /></td>
    <td>3</td>
    </tr>
    <tr>
    <td><input type="checkbox" checked /></td>
    <td>4</td>
    </tr>
    <tr>
    <td><input type="checkbox" /></td>
    <td>3</td>
    </tr>
    </table>
      <script type="text/javascript">
      <!--
    function Element(key, value, rowInd) {
    this.Key = key;
    this.Value = value;
    this.RowIndexes = new Array();
    this.RowIndexes.push(rowInd);
    }Element.prototype.AddRowInd = function(rowInd) {
    this.RowIndexes.push(rowInd);
    };var checker = {
    List: {},
    ErrorList: {},
    AddElement: function(key, value, rowInd) {
    if (this.List[key]) {
    if (this.List[key].Value != value
    && this.ErrorList[key] == undefined) {
    this.ErrorList[key] = this.List[key];
    }
    this.List[key].AddRowInd(rowInd);
    }
    else {
    this.List[key] = new Element(key, value, rowInd);
    }
    },
    ShowError: function() {
    var msg = "";
    for (var p in this.ErrorList)
    {
    msg += "Error Key: " + p + ", RowIndex: " + this.ErrorList[p].RowIndexes.join("; ") + "\n";
    }
    if (msg.length > 0)
    alert(msg);
    }
    };var tbe = document.getElementById("tbeTest");
    var row;
    for (var i=1, len=tbe.rows.length; i<len; i++)
    {
    row = tbe.rows[i];
    checker.AddElement(row.cells[1].innerHTML, row.cells[0].firstChild.checked, i);
    }checker.ShowError();
      //-->
      </script>
     </body>
    </html>
      

  2.   

    俺就是1号假高手,嘎嘎如果使用 HashTable,代码会更简洁。
      

  3.   

    谁说没难度,我说还是有难度的我不信yixianggao能在5分钟内完成
      

  4.   

    呵呵,实现肯定超过 5 分钟,毕竟要一个一个字敲出来。Hash,循环,判断,都是常用结构,属于基本功。
      

  5.   

    呵呵 我写了个简单的方法给大家分享下for(k=0; k<listBlock.rowCount; k++)
    {
    var Number = "Number";
    var exteriorNo1 = listBlock.rowBlock[k].getItem(Number).getValue();
    for(i=1;i<listBlock.rowCount;i++)
    {
    var exteriorNo2 = listBlock.rowBlock[i].getItem(LBL_EXTERIORNO).getValue();
    if(!(exteriorNo1!=exteriorNo2))
    {
    var exteriorNo1checked = document.getElementsByName("HDN_CHK_SELECT")[k].value;
    var exteriorNo2checked = document.getElementsByName("HDN_CHK_SELECT")[i].value;
    if(exteriorNo1checked!=exteriorNo2checked)
    {
    listBlock.rowBlock[k].getItem(LBL_EXTERIORNO).setError(UtilClass.makeMessage(MSG_JSW1020,""));
    PageClass.errFocus = "LBL_EXTERIORNO";
    PageClass.errLine = k;
    PageClass.error = true;
    alert("is error!!!!!");
    break;
    }
    }
    }
      

  6.   

    Web 开发常用手册JScript语言参考.rar
    http://download.csdn.net/source/308916DHTML参考手册.rar
    http://download.csdn.net/source/308913样式表中文手册.chm
    http://download.csdn.net/source/304124
      

  7.   

    学习 js 的关键在于弄清楚基于 prototype 的对象模型!
      

  8.   

    请教你的hashtable是什么,是用Array吗