<HTML>
<HEAD>
<META NAME="save" CONTENT="history">
<STYLE>
  input,select{behavior:url(#default#savehistory);}
</STYLE>
</HEAD>
<BODY>
<INPUT type=text>
<INPUT type=text>
<INPUT type=text>
</BODY>
</HTML>

解决方案 »

  1.   

    net_lover(孟子E章)、flashasp(滾滾長江水): 我的意思是说:
    例如做一个订单:
    它有两个明细,现在我又加了五个明细,可是由于确定时服务器端处理错误,导致无法正确存到数据库里去。那么我们需要返回前页,对资料进行修改,然后再确定。
    可是由于动态增加的行在返回时会丢失,所以造成一旦提交失败,用户都得重新修改明细。我刚才试了一下孟兄的方法,动态增加的信息还是丢失了。
    不知是不是我用错了。
    程序如下:<HEAD>
    <META NAME="save" CONTENT="history">
    <STYLE>
      input,select{behavior:url(#default#savehistory);}
    </STYLE>
    </HEAD><body>
    <form name="frm" method=post ><div width=100% id=thedetailtableDIV>
    <table align="center" bordercolor=cccccc border=1>
    <tr><td colspan=100 align=right>
          <input type="button"  value="拆分" class="bottom" onclick="addOnecargoProcess();">
          &nbsp;
          <input type="button"  value="删除" class="bottom" onclick="delOnecargoProcess();">
          &nbsp;
          <input type="button"  value="完成" class="bottom" onclick="document.frm.submit();">
          &nbsp;
    </td></tr>
      <tr bocolor=eeeeee > 
        <td ><input type=checkbox onclick="selectallcheckbox(this)"></td>
        <td >明细ID</td>
        <td >明细NAME</td>
      </tr>
      <tbody id="tbdDistributions">
    <tr>
    <td ><input type="checkbox" name="record_select" class="check"></td>
    <td ><input type="text" name="detail_id" value='' ></td>
    <td ><input type="text" name="detail_name" value=''></td>
    </tr> <tr height=0 ><td colspan=100 height=0 > 合计</td></tr>
      </tbody> </table>
    </div></form></body><script language=javascript>
    function selectallcheckbox(obj) //全选或全不选
    {
    var tureorfalse=obj.checked;
    var theDetail=tbdDistributions.rows;
    for(var i=0;i<theDetail.length-1;i++)
    {
    theDetail[i].all("record_select").checked=tureorfalse;
    }
    } function addOnecargoProcess() //增加明细
    { var theRecordSelects = document.all("record_select");
    var theFirstSelectedCargo=0;
    for(var i=0;i<theRecordSelects.length;i++)
    {
    if (theRecordSelects[i].checked==true) {theFirstSelectedCargo=i;break;}
    } var newRow = tbdDistributions.rows[theFirstSelectedCargo].cloneNode(true);
    var desRow = tbdDistributions.rows[theFirstSelectedCargo+1];
    desRow.parentElement.insertBefore(newRow,desRow ); }
    function delOnecargoProcess() //删除货物明细
    {
    var theRecordSelects = document.all("record_select");
    if (tbdDistributions.rows.length<3) 
    {
    if (theRecordSelects.checked==true) alert("不可以将所有的明细都删掉");
    return false;
    }
    if (confirm("确定选择正确并且要将这些明细删除")==false) return false;
    for(var i=0;i<theRecordSelects.length;i++)
    {
    if ((theRecordSelects[i].checked==true)&&(tbdDistributions.rows.length>2))
    {
    tbdDistributions.deleteRow(i);
    i=i-1;
    }
    }
    }

    </script>
      

  2.   

    照说应该没问题。IE5上运行就好好的,奇怪的是IE6上就不行了
    不知道是不是IE6不承认这两句话 window.onload = historyOnemore;
    window.onbeforeunload = fixHistory;
      

  3.   

    walkingpoison(walkingpoison) :如果再增加处理页面/内容的话,工作量会大很多,并且如果有十个页面需要这种功能,十个页面都要加上相应的处理出错的页面/内容。
      

  4.   

    在以下函数里加一句return true后,不知为什么,在IE6里会跳出一个弹出框.
    如果用户确定,也可以达到目的,如果用户取消,还会报错.
    请高手帮帮忙.
    焦急中^^^^^^^ function fixHistory() //记住历史
    {
    document.all("theHistoryRecord").innerText=document.all("thedetailtableDIV").innerHTML;
    }
      

  5.   

    signboy(横) :这样不大好吧。
      

  6.   

    这是我在某外国站上看到的效果(好像是M$?---不太记得了)希望对你有所帮助..:)<html>
    <head>
    <style> .userData {behavior:url(#default#userdata);} </style>
    <script for=window event=onload>
    DoLoad();
    </script>
    <script for=window event=onbeforeunload>
    DoSave();
    </script>
    <script>
    function DoSave(){
    foo.setAttribute("content", foo.innerHTML);
    foo.save("EditContent");
    }
    function DoLoad(){
    foo.load("EditContent");
    content = foo.getAttribute("content");
    if (content != null) foo.innerHTML=content; 
    }
    function DoClear(){
    foo.innerHTML = "";
    }
    </script>
    </head>
    <body>
    <p align=center>
    <button onClick='DoSave()'>保存</button>
    <button onClick='DoClear()'>清除</button>
    <button onClick='DoLoad()'>加载</button>
    </p>
    <div id=foo class=userData contentEditable=true style="width:100%;height:90%">
    </div>
    <a href="javascript:document.write('ttest <a href=javascript:history.back()>back</a>')"> cwd </a>
    </body>
    </html>
      

  7.   

    goldenlove(潇洒.net):不错不错不错不错不错不错可是还是有一些问题
    1.IE5不支持contentEditable属性----JK暂时也没地方可用,不过这个属性倒是挺有创意。
    2.如果用这一种方式保存动态明细的方法似乎是同一页面在不同次出现共用的还是同一个("EditContent"),这就造成为了照顾弥补这一点又要做其它的工作。再去仔细试一试。先说一声谢吧!
      

  8.   

    谢谢潇洒的代码。不过JK的问题还是存在
    JK继续等待回答
      

  9.   

    将JK的
    <textarea  name="theHistoryRecord" style="display:none" ></textarea>
    改成
    <input type=hidden  name="theHistoryRecord" value="">将两函数相应的改成如下,就可以解决问题了 function fixHistory() //记住历史
    {
    document.all("theHistoryRecord").value=document.all("thedetailtableDIV").innerHTML.replace(/\n/g),"");
    } function historyOnemore() //恢复历史
    {
    if (document.all("theHistoryRecord").value!="")
    {document.all("thedetailtableDIV").innerHTML=document.all("theHistoryRecord").value;
    }
    }就可以了