【问题标题】:Drop down list doesn't change in IE下拉列表在 IE 中没有变化
【发布时间】:2011-10-20 08:02:19
【问题描述】:

这是我页面的网址:http://www.animalswecare.com/Ads/postad.php There are two fields category and sub category , when category is selected , sub category changes respectively , it is working fine in google chrome , but it has problem with IE, in IE subcategory does not change when category is selected.

【问题讨论】:

标签: javascript mysql html


【解决方案1】:

我鼓励您将 jQuery 用于类似的事情,因为它们确保它几乎可以在所有浏览器上运行。很简单。

http://api.jquery.com/jQuery.ajax/

【讨论】:

  • 我第二点,jQuery或其他框架是跨浏览器的,看看它们。
【解决方案2】:

您将 id "txtHint" 分配给错误的选择元素,将此 id 分配给其父元素,即; TD喜欢

<td id="txtHint"><select name="sub_category"></select></td>

【讨论】:

    【解决方案3】:

    您不能为选择设置 innerHTML。

    相反,您创建一个&lt;div id="txtHintWrapper"&gt;&lt;/div&gt;

    当您进行 innerHTML 更新时,在其中包含 &lt;select&gt;&lt;/select&gt;

    http://support.microsoft.com/kb/276228

    【讨论】:

      【解决方案4】:

      这一行有一个 javascript 错误:

      document.getElementById("txtHint").innerHTML=xmlhttp.responseText;
      

      这是一个已知的bug。查看此 MSDN 错误报告以了解解决方法:BUG: Internet Explorer Fails to Set the innerHTML Property of the Select Object

      这个问题也谈到了它,也可能有用:Javascript - innerHTML not working with HTML select menus

      但是看到 Ajax 请求返回整个 &lt;select&gt; 标签,你应该替换父 &lt;td&gt;innerHTML,而不是 &lt;select&gt; 的 @dev 只是 pointed out

      【讨论】:

        猜你喜欢
        • 2010-12-04
        • 2010-09-09
        • 1970-01-01
        • 2015-11-20
        • 2011-11-15
        • 2017-04-02
        • 1970-01-01
        • 2019-04-07
        • 1970-01-01
        相关资源
        最近更新 更多