views:

13

answers:

0

My javascript CODE

var TDCount = 3;
var i=0;
function insertTD(){
        var possition=document.getElementById('elmnt_pos').value;
        if(possition=="")
        {
                    possition='a';
                    alert('Enter a number!!!');
         }
        if(isNaN(possition))
        {
          alert('Enter a number!!!');
          document.getElementById('elmnt_pos').value='';
        }else{
    var newTD = document.createElement("li");
        var newid='li'+TDCount++;
           newTD.setAttribute("id", newid);
           newTD.setAttribute("onclick","javascript:removenode(this);" );   
    var newText = document.createTextNode(i+"New fruit " + (possition++));
    newTD.appendChild(newText);
    var trElm = document.getElementById("menu");
    var refTD = trElm.getElementsByTagName("li").item(possition-2);
    trElm.insertBefore(newTD,refTD);
        i++;
        }

}
function removenode(th)
{
answer = confirm("Do you really want to Remove Element "+th.id + " ? ")
        if (answer !=0)
        {
        document.getElementById('menu').removeChild(document.getElementById(th.id));
        }
}

the insertTD() function helps to add new li(tag) in the list with new name and position specied at TEXTBOX(id="elmnt_pos"). the removenode(this) function occured on click of each LI tag with their ID(this).and DELETE THE ELEMENT, My problem is that When i add the new item to the list and trying to delete any dynamic added item, it's shown unsuccessful at IE6. Anyone can help me regards on DOM removeChild.