简体   繁体   中英

Why this code for html checkbox works for Firefox and Chrome, but not for IE?

This is related to my previous question : Why html checkbox function only works in IE but not in Firefox or Chrome?

Why the following code does not work in IE :

<body>

<script type="text/javascript">
  function checkAdvSearch(checked)
  {
    console.log("Test");
    if (checked==1)
    {
      document.getElementById("searchTerm2").style.display='';
      document.getElementById("searchField2").style.display='';
    }
    else
    {
      document.getElementById("searchTerm2").style.display='none';
      document.getElementById("searchField2").style.display='none';

      document.getElementById("searchTerm2").value='';
      document.getElementById("searchField2").value='Client Name';
    }
  }
</script>

  <input type="checkbox" name="advSearch" onclick="checkAdvSearch(this.checked);" checked />Advanced Search
  <input type="text" id="searchTerm2" value="" />
  <select id="searchField2" value="clientName" >
    <option>Client Name</option>
    <option>Policy Number</option>
  </select>

</body>
</html>

When I uncheck the box, the other 2 items are supposed to go away, but in IE there is no response, why ?

Edit :

Thanks to Huangism, I found the following message, and clicked it to allow access, now it works OK.

在此处输入图片说明

通过允许IE阻止内容解决了问题。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM