/    Sign up×
Community /Pin to ProfileBookmark

[RESOLVED] Problem with appendChild in IE 6.

Here is the code:

function add_more()
{

table_row1 = document.getElementById(“spec1”).cloneNode(true);
table_row2 = document.getElementById(“spec2”).cloneNode(true);
document.getElementById(“set_table”).appendChild( table_row1 );
document.getElementById(“set_table”).appendChild( table_row2 );
}

works perfectly in firefox, chrome, netscape and opera but doesnt work in IE 6. no errors but doesnt append child to the table.

to post a comment
JavaScript

4 Comments(s)

Copy linkTweet thisAlerts:
@FangJan 15.2010 — Is #set_table the tbody?
Copy linkTweet thisAlerts:
@jewelthiefauthorJan 15.2010 — no its the table id.
Copy linkTweet thisAlerts:
@FangJan 15.2010 — It has to be a tbody
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html lang="en">
<head>
<title></title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">

<script type="text/javascript">
function add_more()
{
table_row1 = document.getElementById("spec1").cloneNode(true);
table_row2 = document.getElementById("spec2").cloneNode(true);
document.getElementById("set_table").appendChild( table_row1 );
document.getElementById("set_table").appendChild( table_row2 );
}
</script>

<style type="text/css">
* {margin:0;padding:0;}
</style>

</head>
<body>
<table border="0" cellpadding="0" cellspacing="0" summary="">
<tbody id="set_table">
<tr id="spec1"><td>foo</td></tr>
<tr id="spec2"><td>bar</td></tr>
</tbody>
</table>
<button type="button" onclick="add_more()">add_more</button>
</body>
</html>
Copy linkTweet thisAlerts:
@jewelthiefauthorJan 15.2010 — thanks. it worked.
×

Success!

Help @jewelthief spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.20,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...