Source: http://blog.csdn.net/caoxicao
Author: caoxi grass
Reprinted please indicate the source
When I inserted the object yesterday, I used <TD id = "tdtr1"> </TD> to insert the object successfully. Today, the object cannot be inserted. The system always prompts "the target object is invalid!
Finally, it was successfully changed to <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>
Actually succeeded! Puzzled!