本帖最后由 devhp 于 2010-01-17 22:12:59 编辑

解决方案 »

  1.   

    <!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>Trees, trees, everywhere </title> 
    </head> 
    <body> 
    <input type="text" value="222" id="0" />
    <input type="text" value="222" id="1" />
    <input type="text" value="222" id="2" />
    <input type="text" value="222" id="3" />
    <input type="text" value="222" id="4" />
    <input type="button" value="ClickMe" id="do" />
    <SCRIPT LANGUAGE="JavaScript">
    <!--
    window.testArr = ["1-222-3","2-333-4","3-444-5","4-555-6","5-666-7"];
    window.onload=function(){
    document.getElementById("do").onclick=function(){
    var inputs = document.getElementsByTagName("input");
    var texts = [];
    for(var i=0;i<inputs.length;i++){
    if(inputs[i].type == "text"){
    texts.push(inputs[i]);
    }
    }
    for(var i=0;i<texts.length;i++){
    cruId = texts[i].id;
    tmp = window.testArr[cruId].split("-");
    tmp[1] = texts[i].value;
    window.testArr[cruId] = tmp.join("-");
    alert[cruId];
    }
    alert(window.testArr);//弹出修改后的值
    }
    alert(window.testArr);//先弹出修改前的值
    }
    //-->
    </SCRIPT>
    </body> 
    </html> 
      

  2.   

    一大早起来就看到大侠这么详细 漂亮的代码。真是非常感谢!由于我没学过Javascript,怕以后再看时有些看不明白,就简化了一下,我也不知道这样子样子简化为不会有什么大问题,只是目的达到而已 ,<SCRIPT>
            function changs(x,y){
               var para,str,str2;
               var cookid_value = getCookie("aaa");//读取名为“aaa”的cookie
               para = cookid_value.split(","); 
               str = para[x].split("-");
               str.splice(1,1,y);
               str2= str.join("-");
               para.splice(x,1,str2);
               doit.innerHTML = "修改成功!"+para;
               addCookie("aaa",para);  更新COOK内容
               get();                  show出数据表格 
            //document.write(para);
            } 
    </SCRIPT>
    下面这句其实是读取COOKIe中的数据时生成的所以 “i” 对应序列
    <div id=cookmm0><input type=text size=1 value=10 onchange=changs("+i+",this.nextSibling.previousSibling.value); /><input style=display:none></div>
    再感谢大侠!