function displayResult()
{
var  damn = document.getElementById("textyar").value;
document.getElementById("oneforty").innerHTML = damn;
var newDIV = document.createElement('div');
newDIV.className = "tweets";
var newspan =document.createElement('span');
newspan.className = "imagespanleft";
var img = document.createElement("IMG");
img.className="image";
img.src = "tweets/me.jpg";
newDIV.innerHTML = document.getElementById('textyar').value;  
document.getElementById('leftmaindiv').appendChild(newDIV).appendChild(newspan).appendChild(img); 
}

this is the code , i m trying to create an interface like twitter where u put in text box and tweet appears below in
problem is it is creating two divs instead of one , i tried insertbefore() as well but same behaviour
plz ask any questions if u r still not clear

Recommended Answers

All 2 Replies

displayResult() seems OK. It creates one new div, <div class="tweets"> with some content, and puts it in leftmaindiv.

If two divs are created then it seems likely that displayResult() is called twice.

In other words the problem probably lies elsewhere, ie. wherever displayResult() is called.

Airshow

thnx for reply , u r right the problem was with form i was calling it in , thnx again :)

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.