我在JSP页面中有以下html,出于某种原因,如果在<script type="text/javascript">
$("#department").autocomplete("department.jsp",{minChars: 4});
之后添加input type
,其余字段未出现在Internet Explorer 8中,则在Firefox和Chrome中会显示。
这可能是什么原因?
<table width="583" border="0">
<tr>
<td>Employee No:</td>
<td> <input type="text" id="employee " name="employee " size="30">
<script type="text/javascript">
$("#department").autocomplete("department.jsp");
</script></td>
</tr>
以下代码无法在IE 8中呈现
<tr>
<td>Join Date </td>
<td>
<input type="text" id="jdate" name="jdate" size="30"/></td>
</tr>
<tr>
<td>Contracrt </td>
<td><input type="text" id="cont" name="cont" size="30"/></td>
</tr>
</table>
修改1
完整的HTML代码
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<%@ page contentType="text/html;charset=windows-1252"%>
<%@ taglib uri="http://java.sun.com/jsf/html" prefix="h"%>
<%@ taglib uri="http://java.sun.com/jsf/core" prefix="f"%>
<html><head>
<link rel="stylesheet" type="text/css" href="css/jquery.autocomplete.css" />
<script type="text/javascript"
src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js"></script>
<script src="js/jquery.autocomplete.js" type="text/javascript"></script>
</head>
<body>
<p>
<f:view>
<h:form id="employeefrm">
<table width="583" border="0">
<tr>
<td>Employee No:</td>
<td> <input type="text" id="employee " name="employee " size="30">
<script type="text/javascript">
$("#department").autocomplete("department.jsp");
</script></td>
</tr>
<tr>
<td>Join Date </td>
<td>
<input type="text" id="jdate" name="jdate" size="30"/></td>
</tr>
<tr>
<td>Contracrt </td>
<td><input type="text" id="cont" name="cont" size="30"/></td>
</tr>
</table>
<p> </p>
</h:form>
</f:view>
</body>
</html>
修改2
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html><head>
<link rel="stylesheet" type="text/css" href="css/jquery.autocomplete.css" />
<script type="text/javascript"
src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js"></script>
<script src="js/jquery.autocomplete.js" type="text/javascript"></script>
</head>
<body>
<p>
<form id="employeefrm" method="post" action="emp.jsp" enctype="application/x-www-form-urlencoded">
<table width="583" border="1">
<tr>
<td>Employee No:</td>
<td> <input type="text" id="employee " name="employee " size="50">
<script type="text/javascript">
$("#department").autocomplete("department.jsp");
</script></td>
</tr>
<tr>
<td>Join Date </td>
<td>
<input type="text" id="jdate" name="jdate" size="30"/></td>
</tr>
<tr>
<td>Contracrt </td>
<td><input type="text" id="cont" name="cont" size="30"/></td>
</tr>
</table>
<p> </p>
<input type="hidden" name="employeefrm" value="employeefrm" /></form>
</body>
</html>
答案 0 :(得分:0)
试试这个:
$(document).ready(function() {
$("#department").autocomplete("department.jsp");});
}
并将其放在
之前