954,597 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

createElement wont show table/div

belama
Posting Shark
963 posts since Mar 2005
Reputation Points: 19
Solved Threads: 2
 

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.

DanceInstructor
Posting Whiz
368 posts since Feb 2005
Reputation Points: 17
Solved Threads: 14
 

That sucks. I really need it to work in IE. The weirdest thing is that the code is really there but wont show up on the page.

belama
Posting Shark
963 posts since Mar 2005
Reputation Points: 19
Solved Threads: 2
 

I added this line of code at the end of the function.
[HTML]document.getElementById("divide").innerHTML = document.getElementById("divide").innerHTML;[/HTML]
The code existed so I just kind of refreshed it. If anything better comes up I will change it.

belama
Posting Shark
963 posts since Mar 2005
Reputation Points: 19
Solved Threads: 2
 

Glad you got it working.

DanceInstructor
Posting Whiz
368 posts since Feb 2005
Reputation Points: 17
Solved Threads: 14
 

The problem is because of
var tr = document.createElement("tr");
var td = document.createElement("td");
In case of IE the above two lines of code doesn't work. Instead it should be
var tr = table.insertRow();
var td = tr.insertCell();

madhurao2684
Newbie Poster
1 post since Mar 2008
Reputation Points: 10
Solved Threads: 0
 
<script language="javascript">
function addElement(){
// Get the value into the input text field
var element=document.getElementById('newElement').value;
if(element==""){
// Show an error message if the field is blank;
document.getElementById('msg').style.display="block";
document.getElementById('msg').innerHTML = "Error! Insert a description for the element";
}else{
// This is the <ul id="myList"> element that will contains the new elements
var container = document.getElementById('myList');
// Create a new <li> element for to insert inside <ul id="myList">
var new_element = document.createElement('li');
new_element.innerHTML = element;
container.insertBefore(new_element, container.firstChild);
// Show a message if the element has been added;
document.getElementById('msg').style.display="block";
document.getElementById('msg').innerHTML = "Elemend added!";
// Clean input field
document..getElementById('newElement').value="";
}
}
</script>
kedman1234
Newbie Poster
2 posts since Jan 2010
Reputation Points: 10
Solved Threads: 0
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You