innerHTML - unknown runtime error.
-
I want add a row to the table dynamically using JavaScript code. In one my application it works fine. But in this application it is prompting error to IE 'unknown runtime error.'. I have use css style sheet in this project. I am not able to find the exact cause and solution of problem. This is an classic asp. I request you all to please help me out to find the solution. I am provide original code of the page: ----------------------------------------------------------------------- <%@LANGUAGE="VBSCRIPT" CODEPAGE="1252"%> <% dim rsItem, strSql, strItem set rsItem = Server.CreateObject("ADODB.RecordSet") strSql = "SELECT * FROM iteam_MSt WHERE status=true;" rsItem.Open strSql, con, 1, 3 do until rsItem.EOF strItem = strItem & "" & rsItem.Fields("details") & "" & vbCrLf rsItem.MoveNext loop rsItem.Close set rsItem = nothing con.close set con = nothing %> New Purchase var ct = 1; function CmdAdd_onclick() { var newTable,startTag,endTag; newTable = ""; startTag = ""; endTag = ""; var trContents0, trContents1, trContents2, trContents3, trContents4, trContents5, trContents6; ct = ct + 1; //Creating a new table startTag+= "<table width='100%' border='0' cellspacing='0' cellpadding='2'>" startTag+="<tr>" startTag+="<td width='2%'>No</td>" startTag+="<td width='28%'>Product Name</td>" startTag+="<td width='17%'>Product Code</td>" startTag+="<td width='10%'>Price</td>" startTag+="<td width='15%'>Quantity</td>" startTag+="<td colspan='2'>Total Amount</td>" startTag+="</tr>" startTag+="<tr>" startTag+="<td colspan='7'></td>" startTag+="</tr>" endTag = "<tr><td colspan='7'></td></tr>" endTag +="<tr><td colspan='5'><div align='right'>Grand Total</div></td><td colspan='2'><input name='txtGrndTotal' type='text' id='txtGrndTotal' style='font-size:12px; border:0px;' value='' size='20' readonly='readonly' /></td></tr>" endTag </x-turndown>
-
I want add a row to the table dynamically using JavaScript code. In one my application it works fine. But in this application it is prompting error to IE 'unknown runtime error.'. I have use css style sheet in this project. I am not able to find the exact cause and solution of problem. This is an classic asp. I request you all to please help me out to find the solution. I am provide original code of the page: ----------------------------------------------------------------------- <%@LANGUAGE="VBSCRIPT" CODEPAGE="1252"%> <% dim rsItem, strSql, strItem set rsItem = Server.CreateObject("ADODB.RecordSet") strSql = "SELECT * FROM iteam_MSt WHERE status=true;" rsItem.Open strSql, con, 1, 3 do until rsItem.EOF strItem = strItem & "" & rsItem.Fields("details") & "" & vbCrLf rsItem.MoveNext loop rsItem.Close set rsItem = nothing con.close set con = nothing %> New Purchase var ct = 1; function CmdAdd_onclick() { var newTable,startTag,endTag; newTable = ""; startTag = ""; endTag = ""; var trContents0, trContents1, trContents2, trContents3, trContents4, trContents5, trContents6; ct = ct + 1; //Creating a new table startTag+= "<table width='100%' border='0' cellspacing='0' cellpadding='2'>" startTag+="<tr>" startTag+="<td width='2%'>No</td>" startTag+="<td width='28%'>Product Name</td>" startTag+="<td width='17%'>Product Code</td>" startTag+="<td width='10%'>Price</td>" startTag+="<td width='15%'>Quantity</td>" startTag+="<td colspan='2'>Total Amount</td>" startTag+="</tr>" startTag+="<tr>" startTag+="<td colspan='7'></td>" startTag+="</tr>" endTag = "<tr><td colspan='7'></td></tr>" endTag +="<tr><td colspan='5'><div align='right'>Grand Total</div></td><td colspan='2'><input name='txtGrndTotal' type='text' id='txtGrndTotal' style='font-size:12px; border:0px;' value='' size='20' readonly='readonly' /></td></tr>" endTag </x-turndown>
Boil it down to the smallest possible amount of code necessary to reproduce the problem. The stuff you've posted has a fair bit of commented-out code, do-nothing code, and code that depends on your particular scenario (and so cannot be used to reproduce the problem by anyone here who might be interested in doing so.)
Citizen 20.1.01
'The question is,' said Humpty Dumpty, 'which is to be master - that's all.'
-
I want add a row to the table dynamically using JavaScript code. In one my application it works fine. But in this application it is prompting error to IE 'unknown runtime error.'. I have use css style sheet in this project. I am not able to find the exact cause and solution of problem. This is an classic asp. I request you all to please help me out to find the solution. I am provide original code of the page: ----------------------------------------------------------------------- <%@LANGUAGE="VBSCRIPT" CODEPAGE="1252"%> <% dim rsItem, strSql, strItem set rsItem = Server.CreateObject("ADODB.RecordSet") strSql = "SELECT * FROM iteam_MSt WHERE status=true;" rsItem.Open strSql, con, 1, 3 do until rsItem.EOF strItem = strItem & "" & rsItem.Fields("details") & "" & vbCrLf rsItem.MoveNext loop rsItem.Close set rsItem = nothing con.close set con = nothing %> New Purchase var ct = 1; function CmdAdd_onclick() { var newTable,startTag,endTag; newTable = ""; startTag = ""; endTag = ""; var trContents0, trContents1, trContents2, trContents3, trContents4, trContents5, trContents6; ct = ct + 1; //Creating a new table startTag+= "<table width='100%' border='0' cellspacing='0' cellpadding='2'>" startTag+="<tr>" startTag+="<td width='2%'>No</td>" startTag+="<td width='28%'>Product Name</td>" startTag+="<td width='17%'>Product Code</td>" startTag+="<td width='10%'>Price</td>" startTag+="<td width='15%'>Quantity</td>" startTag+="<td colspan='2'>Total Amount</td>" startTag+="</tr>" startTag+="<tr>" startTag+="<td colspan='7'></td>" startTag+="</tr>" endTag = "<tr><td colspan='7'></td></tr>" endTag +="<tr><td colspan='5'><div align='right'>Grand Total</div></td><td colspan='2'><input name='txtGrndTotal' type='text' id='txtGrndTotal' style='font-size:12px; border:0px;' value='' size='20' readonly='readonly' /></td></tr>" endTag </x-turndown>
innerHTML does not work well with tables in IE. Firefox works well with it though. I am not sure whether innerHTML was intended to work with nested elements. I found that out when I tried this:
table_ref = document.getElementById(table_name); row_innerHTML = table_ref.rows[1].innerHTML; new_row_ref = table_ref.insertRow(table_ref.rows.length); new_row_ref.innerHTML = row_innerHTML;
The line in block letters produced a runtime error in IE. So, I replaced it with:
// get the node for the table table_ref = document.getElementById(table_name); var table_row_ref = table_ref.rows[1]; new_row_ref = table_ref.insertRow(table_ref.rows.length); cellcount = table_row_ref.cells.length; for (cellindex = 0; cellindex < cellcount; ++cellindex) { new_col_ref = table_row_ref.cells[cellindex].cloneNode(true); new_row_ref.appendChild(new_col_ref); }
Instead of trying to use HTML code, you may also have to use insertRow(), insertColumn() etc. If you want to remove existing rows, use deleteRow() function.
-
I want add a row to the table dynamically using JavaScript code. In one my application it works fine. But in this application it is prompting error to IE 'unknown runtime error.'. I have use css style sheet in this project. I am not able to find the exact cause and solution of problem. This is an classic asp. I request you all to please help me out to find the solution. I am provide original code of the page: ----------------------------------------------------------------------- <%@LANGUAGE="VBSCRIPT" CODEPAGE="1252"%> <% dim rsItem, strSql, strItem set rsItem = Server.CreateObject("ADODB.RecordSet") strSql = "SELECT * FROM iteam_MSt WHERE status=true;" rsItem.Open strSql, con, 1, 3 do until rsItem.EOF strItem = strItem & "" & rsItem.Fields("details") & "" & vbCrLf rsItem.MoveNext loop rsItem.Close set rsItem = nothing con.close set con = nothing %> New Purchase var ct = 1; function CmdAdd_onclick() { var newTable,startTag,endTag; newTable = ""; startTag = ""; endTag = ""; var trContents0, trContents1, trContents2, trContents3, trContents4, trContents5, trContents6; ct = ct + 1; //Creating a new table startTag+= "<table width='100%' border='0' cellspacing='0' cellpadding='2'>" startTag+="<tr>" startTag+="<td width='2%'>No</td>" startTag+="<td width='28%'>Product Name</td>" startTag+="<td width='17%'>Product Code</td>" startTag+="<td width='10%'>Price</td>" startTag+="<td width='15%'>Quantity</td>" startTag+="<td colspan='2'>Total Amount</td>" startTag+="</tr>" startTag+="<tr>" startTag+="<td colspan='7'></td>" startTag+="</tr>" endTag = "<tr><td colspan='7'></td></tr>" endTag +="<tr><td colspan='5'><div align='right'>Grand Total</div></td><td colspan='2'><input name='txtGrndTotal' type='text' id='txtGrndTotal' style='font-size:12px; border:0px;' value='' size='20' readonly='readonly' /></td></tr>" endTag </x-turndown>
see wheather any nonexisting control is referenced