To use two version of jquery in single page

Download js and css

Sample.jsp
<html>
<head>
<meta http-equiv="Content-Language" content="en-us">
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<title>jQuery.noConflict</title>

<%--This is for jquery Button--%>
<%--First jquery version Start--%>

<link rel="stylesheet" href="jquery.ui.all.css">
<script src="jquery-1.9.1.js"></script>
<script src="jquery.ui.core.js"></script>
<script src="jquery.ui.widget.js"></script>
<script src="jquery.ui.button.js"></script>
<link rel="stylesheet" href="demos.css">
  <script>    
$(function() {
         
     $( "input[type=submit], a, button,input[type=Reset]")
     .button()              
});
</script>

<%--First jquery version End--%>

<%--This is for jquery Autocomplete--%>
<%--Second jquery version Start--%>

<script type="text/javascript" src="jquery-1.4.2.min.js"></script>
<script src="jquery.autocomplete.js"></script>
<link rel="stylesheet" type="text/css" href="style.css" />

<script language="javascript" type="text/javascript">
      var jq = jQuery.noConflict (); // jq having the value of $.
                                                 // In your entire script use jq instead of $.
       jq(document).ready(function(){
       jq("#name").autocomplete("auto.jsp");
});
</script>

 <%--By using this conflict you can use any number of jquery version in a single page
          for example:you want to use version 1.10.1 then create another conflict
            var js = jQuery.noConflict (); // jq having the value of $.
                                                    // In your entire script use jq instead of $.
             js(document).ready(function(){
             js("#name").autocomplete("auto.jsp");
--%>

   <%--Second jquery version End--%>

  </head>
   <body>
    <div>
<form name="sample" action="sample">
<table border="0" width="100%" >
          <tr>
                <td colspan="2">/*Second jquery version Start*/</td>
          </tr>
          <tr >
<td>Name</td>
<td><input id="name" type="text" name="name" size="20" ></td>
          </tr>
          <tr>
               <td colspan="2"> /*Second jquery version End*/</td>
          </tr>
          <tr>
<td>Number</td>
<td><input id="no" type="text" name="no" size="20"></td>
  </tr>
          <tr>
              <td colspan="2"> /*First jquery version Start*/</td>
          </tr>
          <tr>
             <td colspan="2"><input type="submit" value="submit"></td>
          </tr>
          <tr>
            <td colspan="2">/*First jquery version End*/</td>
         </tr>
  </table>
  </form>  
  </div>
  </body>
  </html>
auto.jsp

<%@page import="java.sql.*"%>
<%@page import="java.util.ArrayList"%>
<%@page import="com.hrm.connection.Dbconnection" %>
<%
try
{
Class.forName("com.mysql.jdbc.Driver");
Connection  c=DriverManager.getConnection("jdbc:mysql://localhost:3306/xxx","root","root");
Statement st1=c.createStatement();
ResultSet rs=st1.executeQuery("select * from name");
String product="";
ArrayList aa=new ArrayList();
while(rs.next())
{
aa.add(rs.getString("name"));
System.out.println(rs.getString("name"));
}
int cnt=1;
String query = (String)request.getParameter("q");
for(int i=0;i<aa.size();i++)
{
String temp=(String) aa.get(i);

if(temp.toUpperCase().startsWith(query.toUpperCase()))
{
out.print(temp+"\n");
if(cnt>=10)
break;
cnt++;
}
}
}
catch(Exception ex)
{
System.out.println("error"+ex);
}

%>




0 comments:

Post a Comment

 
java4practices © 2013 | Designed by Ganesh Rengarajan