Skip to content

IE Javascript problem?

What would you expect the bit of javascript below to do?


    <select id="testing">

        var testing = document.getElementById('testing');
        var georgeOpt = new Option("George", 1);
        var paulOpt = new Option("Paul", 2);
        var johnOpt = new Option("John", 3);
        var ringoOpt = new Option("Ringo", 4);
        ringoOpt.selected = true;


In Firefox the SELECT is displayed with Ringo selected, in IE John is selected. If you swap the last two lines of script – Ringo is selected in both browsers. Easily fixed so its no biggie. I guess it doesn’t really make sense to tell an OPTION it is selected before it belongs to a SELECT?

Post a Comment

Your email is never published nor shared. Required fields are marked *