我正在调试一个JavaScript/JSP/Struts应用程序,它有一个复选框,用于高级搜索,当它被选中时,其他2个项目应该显示在页面上供用户输入更多信息,但这只适用于IE浏览器,但不是Firefox或Chrome浏览器,当在其他两个浏览器上检查时没有响应,为什么?以及如何使它在所有浏览器中都能正常工作?为什么html复选框功能仅适用于IE,但不适用于Firefox或Chrome?
<script type="text/javascript">
function checkAdvSearch(checked) {
if(checked) {
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("searchLOB").style.display = 'none';
document.getElementById("searchTerm2").value = '';
document.getElementById("searchField2").value = 'clientName';
document.getElementById("searchStatus").value = '';
document.getElementById("searchLOB").value = '';
}
}
</script>
...
<!-- for advanced search -->
<td Valign=top width=300>
<input type="checkbox" name="advSearch" onclick="checkAdvSearch(this.checked);" tabindex="5"/>Advanced Search
<html:text property="searchTerm2" value="" style="display:none" tabindex="6"/>
</td>
<td Valign=top width=178>
<html:select property="searchField2" onchange="showOptions2(this.form)" value= "" style="display:none" tabindex="7">
<html:option value="clientName">Insured Name</html:option>
<html:option value="policy">Policy Number</html:option>
...
</html:select>
</td>
...
它适用于Firefox和Chrome,但不适用于IE。感谢您的示例代码,至少您指出了我的正确方向。 – Frank 2014-10-28 00:00:00