javascript freezeing ie8
<p>Can someone tell me why does this code freeze ie8? It is supposed to generate input fields. In firefox, safari, chrome it works, but in in8 when i press generate button it freezes</p>

<pre><code>var monthNames = [ "Ianuarie", "Februarie", "Martie", "Aprilie", "Mai", "Iunie", "Iulie", "August", "Septembrie", "Octombrie", "Noiembrie", "Decembrie" ];

function buildMonthlyEntries() {
    var startDate = new Date(document.getElementById('datastart').value);
    var endDate = new Date(document.getElementById('dataend').value);
    if (startDate == "Invalid Date" || endDate == "Invalid Date") { return null; }

    var monthlyEntries = document.getElementById('monthlyEntries');
    monthlyEntries.innerHTML = "";

    // inclusiv dataend
    endDate.setMonth(endDate.getMonth() + 1);

    // start with startDate; loop until we reach endDate
    for (var dt = startDate; 
           ! ( dt.getFullYear() == endDate.getFullYear() &amp;&amp; dt.getMonth() == endDate.getMonth() );  
           dt.setMonth( dt.getMonth() + 1 )
    ) {
        monthlyEntries.appendChild( document.createTextNode(
                  monthNames[dt.getMonth()] + " " + String(dt.getFullYear()).substring(2)
              ) );
        var textElement = document.createElement('input');
        var textElement2 = document.createElement('input');
        var textElement3 = document.createElement('input');
        textElement.setAttribute('type', 'text');
        //textElement.setAttribute('name', 'entry['+ monthNames[dt.getMonth()] + + String(dt.getFullYear()).substring(2) + ']');
     textElement.setAttribute('name', 'entry[]');
        textElement2.setAttribute('type', 'hidden');
        textElement2.setAttribute('name', 'luna[]');
        textElement2.setAttribute('value', '' + monthNames[dt.getMonth()] + '');
        textElement3.setAttribute('type', 'hidden');
        textElement3.setAttribute('name', 'an[]');
        textElement3.setAttribute('value', '' + String(dt.getFullYear()) + '');
        monthlyEntries.appendChild(textElement);
        monthlyEntries.appendChild(textElement2);
        monthlyEntries.appendChild(textElement3);
        // adauga br
        // monthlyEntries.appendChild(document.createElement("br"));
    }
    return null;
}
</code></pre>
