Data Combo Box Shows year ahead in IE7 - Help!

Discussion in 'JavaScript' started by getwiththeprogram, Aug 2, 2007.

  1. #1
    Hi,

    Having some problems with a script in IE5.5-6.0 it works fine and shows the correct four digit year (once changed a xml file populates the screen) but in IE7 the combo box displays a year ahead so shows 2008 for those users only.

    Any ideas where I can start, is it possible to add a function so if the useragent is IE7 it can deduct a year, Not ideal though?

    The code which builds the box is:

    function populateYearComboBox () {
    var combo = document.getElementById ('comboNewYear');
    if (!combo) return;
    var offset = 5;
    var d = ISODateToDate (startingDate);
    var y = d.getFullYear();
    var i;
    for (i=y-offset;i<=y+offset;i++) {
    var oOption = document.createElement ("OPTION");
    oOption.text=i;
    oOption.value=i;
    oOption.id='year' + i;
    // strange !!! you have to select the next one !!!
    oOption.selected = (i == y+1);
    combo.add (oOption);
    }
    }
     
    getwiththeprogram, Aug 2, 2007 IP