B
benkasminbullock
I have a script which adds rows to an HTML table. However, the script
functions only for Firefox and not for Internet Explorer. Here is a
test case which works on Firefox 2.0.0.8 but does not work on Internet
Explorer 6.0.
Can anyone explain why this does not work, and is there a way to make
it work with Internet Explorer?
What bothers me is that modifying the script slightly to change the
table to a <ul> and the <tr> to a <li> does work with Internet
Explorer.
Thanks for any help.
%%%%%%%%%%%%%%% start of example
<html>
<head>
<script>
function add_a_row()
{
alert ("Add a row");
var cell = document.createElement("td");
cell.appendChild(document.createTextNode("Second"));
var row = document.createElement("tr");
row.appendChild(cell);
var mytable = document.getElementById("mytable");
mytable.appendChild(row);
}
</script>
<style>
table { border-style: outset; border-width: 3; }
td { border-style: inset; border-width: 3; font-size: 50; }
</style>
</head>
<body>
<table id="mytable">
<tr><td>First</td></tr>
</table>
<form>
<input type="button"
onclick="add_a_row()"
value="add a row">
</form>
</body>
</html>
%%%%%%%%%%%%%%%%% end of example
functions only for Firefox and not for Internet Explorer. Here is a
test case which works on Firefox 2.0.0.8 but does not work on Internet
Explorer 6.0.
Can anyone explain why this does not work, and is there a way to make
it work with Internet Explorer?
What bothers me is that modifying the script slightly to change the
table to a <ul> and the <tr> to a <li> does work with Internet
Explorer.
Thanks for any help.
%%%%%%%%%%%%%%% start of example
<html>
<head>
<script>
function add_a_row()
{
alert ("Add a row");
var cell = document.createElement("td");
cell.appendChild(document.createTextNode("Second"));
var row = document.createElement("tr");
row.appendChild(cell);
var mytable = document.getElementById("mytable");
mytable.appendChild(row);
}
</script>
<style>
table { border-style: outset; border-width: 3; }
td { border-style: inset; border-width: 3; font-size: 50; }
</style>
</head>
<body>
<table id="mytable">
<tr><td>First</td></tr>
</table>
<form>
<input type="button"
onclick="add_a_row()"
value="add a row">
</form>
</body>
</html>
%%%%%%%%%%%%%%%%% end of example