Question

I am running into some compatibility issues running the below script in IE 7, 8, 9 and even 10 if I have compatibility mode disabled. I checked a lot of functions browser compatibility but cant seem find the issue. Does anything stand out to anyone? The one change I made was instead of setting the attributes by the arrayname[index].attribute I now use setAttribute

<script>

var counter = 0;

function moreFields() {
    counter++;
var newFields = document.getElementById('add_contact').cloneNode(true);
var newInputs = newFields.getElementsByTagName('input');
newFields.style.display = 'block';
newInputs.id = '';
for (var index = 0; index < newInputs.length; index++) {
    console.log(newInputs[i]);
}





    for (var i=0; i<newInputs.length;i++) {
        var theName = newInputs[i].name

            if(theName)
            newInputs[i].setAttribute('name',theName + counter);
            newInputs[i].setAttribute('id',newInputs[i].id+"_"+counter);




    }
    var insertHere = document.getElementById('additional');
    insertHere.parentNode.insertBefore(newFields,insertHere);

}


</script>
Was it helpful?

Solution

the problem is the console.log. internet explorer does not support console

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top