-1

我在 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>&nbsp;</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>&nbsp;</p>
     <input type="hidden" name="employeefrm" value="employeefrm" /></form>

    </body>
</html>
4

1 回答 1

0

尝试这个 :

 $(document).ready(function() {
 $("#department").autocomplete("department.jsp");});
}

并把它放在前面

于 2013-03-25T09:25:32.803 回答