Hi,
I have the following code working great in Firefox but not IE.
Please help...
Please help...
I have the following code working great in Firefox but not IE.
Please help...
Code:
<html>
<head>
<title>Page title</title>
<script language="javascript">
function clone_rows(myType)
{
if (myType == 'items') {
var clone_table=document.getElementById("clone_table");
}
if (myType == 'files') {
var clone_table=document.getElementById("clone_table_files");
}
var clones=[];
var startIndex=0;
var rows=clone_table.getElementsByTagName("tr");
for (var i=0; i < rows.length; i++) {
if (rows[i].className=='clone') {
rows[i].className="";
clones.push(rows[i]);
startIndex=i;
}
}
var new_name_number=parseInt((parseInt(rows.length)-2) / parseInt(clones.length));
for (i=0; i < clones.length; i++) {
var new_row=clone_table.insertRow(startIndex+i+1);
if (i% 2 == 0)
var bgcolor = "C3D6E8";
else
var bgcolor = "CCCCCC";
if (myType == 'files') {
var last_row= clone_table.rows.length;
if (last_row% 2 == 0)
var bgcolor = "CCCCCC";
else
var bgcolor = "C3D6E8";
}
if (i == clones.length-1 && i != 0)
var bgcolor = "000000";
new_row.style.backgroundColor = bgcolor;
new_row.className="clone";
var cloned_children=clones[i].getElementsByTagName("td");
for (var j=0; j < cloned_children.length; j++) {
var new_cell=new_row.insertCell(-1);
new_cell.innerHTML=cloned_children[j].innerHTML;
// new_cell.innerHTML=new_cell.innerHTML.replace(/name=\"[0-9]{0,2}/g, "name=\"");
// new_cell.innerHTML=new_cell.innerHTML.replace(/name=\"/g, "name=\"" + new_name_number + "#");
// new_cell.innerHTML=new_cell.innerHTML.replace(/#/g, "@");
// This replaces existing digits and _ and adds in the new # with a _
new_cell.innerHTML=new_cell.innerHTML.replace(/name=\"\d*_*/g, "name=\"" + new_name_number + "_");
}
}
var hiddenCount = document.createElement("input");
hiddenCount.setAttribute("type", "hidden");
if (myType == 'items') {
hiddenCount.setAttribute("name", "theItemCount");
}
if (myType == 'files') {
hiddenCount.setAttribute("name", "theFileCount");
}
hiddenCount.setAttribute("value", new_name_number);
document.getElementById("clone_table").appendChild(hiddenCount);
}
</script>
</head>
<body>
<table>
<tr>
<td></td>
<td align="right"></td>
</tr>
</table>
<table width="900" border="0" cellspacing="0" cellpadding="0">
<tr>
<td><img src="#" width="20" height="10" border="0"></td>
<td><br>
<form action="" method="get" name="theForm">
<table id="clone_table">
<tr >
<td colspan="3">Item1</td>
</tr>
<tr bgcolor="" valign="top" class="clone">
<td>Item2</td>
<td><input type=text name="0_Item2" size="5" maxlength="350" value=""></td>
</tr>
<tr bgcolor="" valign="top" class="clone">
<td>Item3</td>
<td><input type=text name="0_Item3" size="5" maxlength="350" value=""></td>
</tr>
<tr valign="top" class="clone">
<td>Item4</td>
<td><input type=text name="0_Item4" size="5" maxlength="350" value=""></td>
</tr>
<tr bgcolor="" valign="top" class="clone">
<td>Item5</td>
<td colspan="2"><input type=text name="0_Item5" size="40" maxlength="250" value=""></td>
</tr>
<tr bgcolor="" valign="top" class="clone">
<td>Item6</td>
<td>
<select name="0_Item6">
<option value="">--None--</option>
<option value="001"
>001</option>
<option value="002"
>002</option>
<option value="003"
>003</option>
<option value="004"
>004</option>
</select>
</td>
</tr>
<tr class="clone">
<td>
Item7</td>
<td>
<select name="0_Item7">
<option value="">--None--</option>
<option value="101"
>101</option>
<option value="102"
>102</option>
<option value="103"
>103</option>
</select><br>
</td>
</tr>
<tr class="clone">
<td></td>
<td></td>
</tr>
<tr>
<td colspan="3"><input type="button" value="Add More Items" onclick="clone_rows('items'); return false;" /></td>
</tr>
</table>
<br />
<table>
<tr valign="top">
<td><input name="submit_form" type="submit" value="Submit" /></td>
<td align="right"></td>
</tr>
</table>
</form>
</td>
<td></td>
</tr>
</table>
<br><br><br><br>
</body>
</html>
Comment