Hi All.
This code works very fine in Firefox but not in I.E.
Can anybody help me out?
it gives ... "Unknown Runtime Error" in I.E.
This code ... Stores N*2 Matrix at Client Side & provide the mean to
send the matrix to server side.
================================================== =====
<html>
<head>
<title>Test Page</title>
<meta http-equiv="Content-Type" content="text/html;
charset=iso-8859-1">
<script type="text/javascript">
function addToTable()
{
var value1 = document.frmSecondary.txtValue1.value;
var value2 = document.frmSecondary.txtValue2.value;
document.getElementById("tblRecords").innerHTML += "<tr><td>" + value1
+
"</td><td>" + value2 +
"</td></tr>";
document.frmSecondary.txtValue1.value = "";
document.frmSecondary.txtValue2.value = "";
document.frmSecondary.txtValue1.focus();
}
/*
This function should be called on the onSubmit of primary form
*/
function processFormSubmit()
{
processRecordsTable();
return true;
}
/*
This function processes the Records table to output all rows in the
table
as hidded fields in the frmMain form.
In that form there is a hidden field called "rowCount" which stores the
number of rows
of the n*2 matrix (i.e. the value of n)
AT SERVER SIDE - DO THE FOLLOWING THING
---------------------------------------
Read that rowCount attribute into variable n
for i=1 to n
'for the ith row the value of column1 will be in a attribute named as
'Value1-' & i
'for the ith row the value of column2 will be in a attribute named as
'Value2-' & i
next
*/
function processRecordsTable()
{
//store the table in a variable (for easy access)
var tbl = document.getElementById("tblRecords");
//store the form in a variable (for easy access)
var frm = document.frmMain;
//get the number of rows in the table tblRecords
var rowCount = tbl.rows.length;
//save this count to a hidden field in the form
frm.rowCount.value = rowCount - 1;
//now loop through the table rows and output all values as hidden
fields in form frmMain
//looping from 1 because the 0th row has the table headings
for (var i = 1; i < rowCount; i++)
{
frm.innerHTML += "<input type=hidden name='Value1-" + i + "' value='" +
tbl.rows[i].cells[0].innerHTML + "'>";
frm.innerHTML += "<input type=hidden name='Value2-" + i + "' value='" +
tbl.rows[i].cells[1].innerHTML + "'>";
}
}
</script>
</head>
<body>
<form name="frmMain" action="something.asp" method="post"
onSubmit="return processFormSubmit();">
<table cellpadding="5" cellspacing="5">
<tr>
<td>Enter name</td>
<td><input type="text" name="txtName"></td>
</tr>
<tr>
<td><input type="submit" value="Submit"></td>
</tr>
</table>
<!-- HIDDEN FIELDS -->
<input type="hidden" name="rowCount" value="0">
</form>
<form name="frmSecondary">
<table cellpadding="5" cellspacing="5" border="1">
<tr>
<td>Enter Value 1</td>
<td><input type="text" name="txtValue1"></td>
</tr>
<tr>
<td>Enter Value 2</td>
<td><input type="text" name="txtValue2"></td>
</tr>
<tr>
<td><input type="button" value="Add" onClick="addToTable();"></td>
</tr>
</table>
</form>
<table id="tblRecords" cellpadding="5" cellspacing="5">
<tr>
<td><b>Value 1</b></td>
<td><b>Value 2</b></td>
</tr>
</table>
</body>
</html>
================================================== =====
Thanks in Advance.