| | |
createElement wont show table/div
Please support our JavaScript / DHTML / AJAX advertiser: PostgreSQL or MySQL? Compare and contrast the two most popular open source databases
![]() |
I've come up with this code and cant figure out why nothing appears when I press the button. The table is soposed to show. Probably something really simple cuz I often stuck on stupid things.
[HTML]<html>
<head>
<script type="text/javascript">
function appendtable() {
var div = document.getElementById("divide");
var ControlsDesign = document.createElement("div");
var table_cd = document.createElement("table");
var tr_cd = document.createElement("tr");
var td_cd = document.createElement("td");
var table_content = document.createElement("table");
var tr = document.createElement("tr");
var td = document.createElement("td");
var t = document.createTextNode("Some text");
td.appendChild(t);
tr.appendChild(td);
table_content.appendChild(tr);
td_cd.appendChild(table_content);
tr_cd.appendChild(td_cd);
table_cd.appendChild(tr_cd);
ControlsDesign.appendChild(table_cd);
div.appendChild(ControlsDesign);
alert(document.getElementById("divide").innerHTML);
}
</script>
</head>
<body bgcolor="#999999">
<div id="divide" height="100"></div><input type="button" onclick="appendtable()" value="Press me">
</body>
</html>[/HTML]
Thanks for helping.
[HTML]<html>
<head>
<script type="text/javascript">
function appendtable() {
var div = document.getElementById("divide");
var ControlsDesign = document.createElement("div");
var table_cd = document.createElement("table");
var tr_cd = document.createElement("tr");
var td_cd = document.createElement("td");
var table_content = document.createElement("table");
var tr = document.createElement("tr");
var td = document.createElement("td");
var t = document.createTextNode("Some text");
td.appendChild(t);
tr.appendChild(td);
table_content.appendChild(tr);
td_cd.appendChild(table_content);
tr_cd.appendChild(td_cd);
table_cd.appendChild(tr_cd);
ControlsDesign.appendChild(table_cd);
div.appendChild(ControlsDesign);
alert(document.getElementById("divide").innerHTML);
}
</script>
</head>
<body bgcolor="#999999">
<div id="divide" height="100"></div><input type="button" onclick="appendtable()" value="Press me">
</body>
</html>[/HTML]
Thanks for helping.
You will be happy to know that this works in Firefox, but not in Internet Explorer. I'm not sure what the exact problem is, but it has something to do with the DOM and browser compatibility. If I figure it out I will let you know.
![]() |
Similar Threads
- display:block to show a table? (JavaScript / DHTML / AJAX)
- Screen just wont show anything (Troubleshooting Dead Machines)
- msn messenger..contacts display pictures wont show (Windows NT / 2000 / XP)
- msn messenger...wont show contacts display pics (Windows Software)
- Need help diplaying null values (PHP)
Other Threads in the JavaScript / DHTML / AJAX Forum
- Previous Thread: How do i color something like a blueprint?
- Next Thread: Date function in Drop-Down Box
| Thread Tools | Search this Thread |
acid2 ajax ajaxcode ajaxexample ajaxhelp ajaxjspservlets animate array automatically beta box browser bug calendar captchaformproblem cart close codes column css cursor date debugger decimal dependent design disablefirebug dom download dropdown element embed engine enter error events ext file firefox focus form frameworks getselection google gwt gxt hiddenvalue highlightedword hint html htmlform ie7 iframe images index java javascript javascripthelp2020 jawascriptruntimeerror jquery jsp libcurl listbox maps masterpage media menu microsoft mimic mp4 onmouseoutdivproblem onmouseover paypal pdf php player position post problem programming prototype redirect regex safari scale scriptlets scroll search security select software sql text textarea unicode w3c website window windowofwords windowsxp





