出處:http://blog.csdn.net/caoxicao
作者:草惜草
轉載請註明出處
昨天插入的時候用 <td id="tdtr1"></td>插入成功,今天卻不行了,總是提示“目標對象無效”,不解!
最後改成<div id="tdtr1"></div>居然成功!!!
function InsertNewLine(Id)
{
var Maxline=window.form1.Maxline.value;
var obj=eval("line"+Id);
var objDiv=eval("tdtr"+Id);
var MyLine
var re0;
re0=/(but_display|LineSeq|TransferID|TransferWhse|Consignee|Vendor|pickVendor|AllocateQty|AllocateType)(/()?(')?[1-9][0-9]?(')?(/))?/g;
var re1;
re1=/>[1-9][0-9]?</;
var modifiedHTML;
modifiedHTML=obj.innerHTML;
modifiedHTML=modifiedHTML.replace(re0,"$1"+"$2"+"$3"+String(Maxline)+"$4"+"$5");
modifiedHTML=modifiedHTML.replace(re1,"><");
var addHTML;
addHTML = "<table width=/"100%/" id=line"+String(Maxline)+" style=/"DISPLAY: block/" border=/"0/" cellspacing=/"1/" cellpadding=/"0/" align=/"center/" bgcolor=/"#decfa8/">";
addHTML = addHTML + modifiedHTML;
addHTML = addHTML + "</table>";
objDiv.insertAdjacentHTML("beforeEnd",addHTML);
eval("document.all('LineSeq" + Maxline+"').value =String(Maxline)");
eval("document.all('TransferID" + Maxline+"').value =''");
eval("document.all('TransferWhse" + Maxline+"').value =''");
eval("document.all('Consignee" + Maxline+"').value =''");
eval("document.all('Vendor" + Maxline+"').value =''");
eval("document.all('Vendor" + Maxline+"name').value =''");
eval("document.all('pickVendor" + Maxline+"').value =''");
eval("document.all('AllocateQty" + Maxline+"').value =''");
window.form1.Maxline.value = parseInt(Maxline)+1;
MyLine = parseInt(Maxline);
====================
<div id="tdtr1">
<table width="100%" id=line1 style="DISPLAY: block" border="0" cellspacing="1" cellpadding="0" align="center" bgcolor=#decfa8>
... ...
</div>
居然成功!不解!