ERROR in <SELECT>'s innerHTML. Is this IE's bug? Or MSHTML's bug?

Discussion in 'Internet Explorer' started by earthdog.zhhw, Jan 10, 2007.

  1. When I use JavaScript to modify <SELECT>'s option using innerHTML property. I
    find the following error.
    First, <SELECT>'s options are the following:
    <option value="a">a</option>
    when I change the options with the following:
    <option value='b'>b</option>
    it shows me that <SELECT>'s innerHTML is:
    b</OPTION>

    I test this in IE6 & IE7 (build 7.0.5730.11 CHS), and MSHTML version is 4.0
    (implemented by .NET assembly
    Microsoft.mshtml, Version=7.0.3300.0, Culture=neutral,
    PublicKeyToken=b03f5f7f11d50a3a). Both has the error
    I mentioned before. But if I test this in Firefox/2.0.0.1, it goes fine.

    Change <P>'s innerHTML goes fine in IE6, IE7 & Firefox/2.0.0.1.

    So I can only change <SELECT>'s options using DOM.

    Does anybody knows this bug?

    The HTML I used shows below:

    <html>
    <head>
    <title>innerHTML</title>
    <script type="text/javascript">
    <!--
    function changeOptions()
    {
    var p = document.getElementById("p1");
    p1.innerHTML = "<select id='select2'><option value='b'>b</option></select>";

    var select = document.getElementById("select1");
    alert(select.innerHTML);
    select.innerHTML = "<option value='b'>b</option>";
    alert(select.innerHTML);
    }
    //-->
    </script>
    </head>

    <body>
    <form>
    <p id="p1"></p>
    <select id="select1">
    <option value="a">a</option>
    </select>
    <input type="button" value="Change Options" onclick="changeOptions();" />
    </form>
    </body>
    </html>
     
    earthdog.zhhw, Jan 10, 2007
    #1
    1. Advertisements

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.