help with cloneNode script

    Date: 06/22/06 (Javascript Community)    Keywords: html

    I am trying to create a script that will add a new field when the user clicks on a link. I am using the cloneNode feature to take the existing field and make a new one based on that. This script works great in firefox on my mac, but fails on IE 6 in Windows.

    The script: 



    var counter = 0;

    function addGiftCard()
    {
        counter++;
        $('cardCount').value=counter;
        var newFields = $('GiftCard').cloneNode(true);
        newFields.id = '';
        newFields.style.display = 'block';
        //alert("innerhtml = " + newFields.childNodes[1].innerHTML);
        newFields.childNodes[1].id = "giftCardDesc" + (counter + 1 );
       
        newFields.childNodes[1].innerHTML = "Gift Card " + (counter + 1) + " - Amount";
       
        var newField = newFields.childNodes;
        for (var i=0;i    {
            var theName = newField[i].name
            if (theName)
                newField[i].name = theName + counter;
               
           
        }
       
        var insertHere = document.getElementById('writeroot');
        insertHere.parentNode.insertBefore(newFields,insertHere);
    }


    And here is the HTML:

    + Add Gift card


       Gift Card 1 - Amount$




     Any ideas why this works on firefox and fails in IE?

    Source: http://community.livejournal.com/javascript/103463.html

« Noob Questing || passwords, member areas, etc. »


antivirus | apache | asp | blogging | browser | bugtracking | cms | crm | css | database | ebay | ecommerce | google | hosting | html | java | jsp | linux | microsoft | mysql | offshore | offshoring | oscommerce | php | postgresql | programming | rss | security | seo | shopping | software | spam | spyware | sql | technology | templates | tracker | virus | web | xml | yahoo | home