Autocomplete Textbox in JSP

Autocomplete plugin for jQuery can be used to provides list of suggestions, as we type letter/s in our textbox.

Last few days I was breaking my head for auto complete textbox in JSP with autocomplete (v1.3) jQuery plugin.  I had tried all the way, but I was not getting the list on the textbox. Even I posted the problem in DaniWeb, discussion community, but there also I didn’t get any solution.

Later after long try I found the solution. Actually autocomplete v1.1 works with JSP very well, but earlier is not working with JSP.  With v1.1, I got output in this way.

For the given example, I have created a JSP file which will contain a list of country name. If you want to create the list with the data of the database, you will need to select the data from the database and print the data in JSP page with new line after each data.

//list.jsp
<%@page import="java.util.Iterator"%>
<%@page import="java.util.List"%>
<%@page import="java.util.ArrayList"%>
<%
	String countries[] = {
						 	"Afghanistan",
							"Albania",
							"Algeria",
							"Andorra",
							"Angola",
							"Antigua and Barbuda",
							"Argentina",
							"Armenia",
							.
							.
							"Yemen",
							"Zambia",
							"Zimbabwe"
							};

	String query = (String)request.getParameter("q");
	//System.out.println("1"+request.getParameterNames().nextElement());
	response.setHeader("Content-Type", "text/html");
	int cnt=1;
	for(int i=0;i<countries.length;i++)
	{
		if(countries[i].toUpperCase().startsWith(query.toUpperCase()))
		{
			out.print(countries[i]+"\n");
			if(cnt>=10)
				break;
			cnt++;
		}
	}
%>

Then we have a JSP or HTML page which will request to the server side page autocomplete function of autocomplete plugin.

//index.jsp
<!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/style.css" />
	<script type="text/javascript" src="JS/jquery-1.4.2.min.js"></script>
	<script src="JS/jquery.autocomplete.js"></script>
</head>
<body>
	<div style="width: 300px; margin: 50px auto;">
		<b>Country</b>   : <input type="text" id="country" name="country" class="input_text"/>
	</div>

</body>
<script>
	jQuery(function(){
		$("#country").autocomplete("list.jsp");
	});
</script>
</html>

I have used the following styles to make it suitable for my site. You can modify according to your requirements.

.ac_results {
 padding: 0px;
 border: 1px solid #ff7c08;
 background-color: white;
 overflow: hidden;
}

.ac_results ul {
 width: 100%;
 list-style-position: outside;
 list-style: none;
 padding: 0;
 margin: 0;
}

.ac_results li {
 margin: 0px;
 padding: 2px 5px;
 cursor: default;
 display: block;
 color: #972800;
 font-family:Arial, Helvetica, sans-serif;
 /*
 if width will be 100% horizontal scrollbar will apear
 when scroll mode will be used
 */
 /*width: 100%;*/
 font-size: 12px;
 /*
 it is very important, if line-height not setted or setted
 in relative units scroll will be broken in firefox
 */
 line-height: 16px;
 overflow: hidden;

}

.ac_loading {
 background: white url(../images/indicator.gif) right center no-repeat;
}

.ac_odd {
 background-color: #fef2d8;
}

.ac_over {
 background-color: #febb80;
 color: white;
}

.input_text{
 font-family:Arial, Helvetica, sans-serif;
 font-size:12px;
 border:1px solid #FF7C08;
 padding:2px;
 width:150px;
 color:#802900;
 background:white url(../images/search.png) no-repeat 3px 2px;
 padding-left:17px;
}

Demo can be viewed here.

Source files are available here.

Some extra features could be possible from earlier version of autocomplete, So if anyone find the solution in newer vision, please do comment me.

About these ads

166 Responses to Autocomplete Textbox in JSP

  1. bet365 says:

    Good day I was luck to seek your topic in baidu
    your subject is superb
    I get much in your theme really thank your very much
    btw the theme of you blog is really wonderful
    where can find it

  2. Mohammed says:

    Hi,
    i’m not much familiar with jquery could u pls send me the code where i can get the values from database

    • Prashant says:

      I would like to suggest you to download my project from the above link.
      Then in list.jsp, select the data according to received parameter using like operator of SQL
      and print those selected data using loop.
      I hope you can do it now.

      • Mohammed says:

        Hi Prashant,

        I tried ur code , but it’s not working in my system. I’m using IE 8 and i’m not able to understand the jquery code, pls help me.

      • Prashant says:

        does my demo link worked in ur browser??

      • Mohammed says:

        yes

      • Mohammed says:

        yes, it’s working . when i used your code in my application it;s not working

      • Prashant says:

        Okay.. Let me tell you procedure..
        1) create JS folder in your application
        2) inside that folder paste jquery.autocomplete.js and jquery-1.4.2.min.js
        3) link js files from index.jsp(the file in which you want to insert auto textbox)
        4) in list.jsp (to display list from db) write code to print all list of data
        5) in index.jsp (auto textbox file) assign the list.jsp url in javascript autocomplete function

        jQuery(function(){
        $("#country").autocomplete("list.jsp");
        });

  3. Mohammed says:

    Hi,
    i’m not much familiar with jquery could u pls send me the code where i can get the values from database through auto complete.
    i’m doing on Struts1.0 .

  4. nikki says:

    Hi,
    i am trying to make a link between a list entry and to a text box…using jsp , javabean ,mysql and javaScript ..My Q is: I have a drpdownlist, textbox and search button.
    suppose there are some 3/4 entries in a dropdown list.If i select an entry from the list and give a related data(suppose in list i select TITLE and in text box i entered atomic……)so when i click search button it should show me all the entris related to letter starts with ato………………
    Plz give me some idea.I know how to retrieve set of related entries from the database using the JSP.

    • Prashant says:

      Hello nikki,
      I think for this you have to first take take beginning three letters from the textbox field.
      and then that letters you can use in sql query with Like clause.
      so you will get all those value from the table data which begins from those substrings.
      something like this:

      str=textbox_string.substring(0, 2);
      query=”SELECT FROM `database`.`table` where field like ‘”+ str+”%'”;

  5. nikki says:

    Thanks for your reply.I did the above query and also got the result.But can i know how will i make a link between a dropdown list and text box ,so that when i search i will get the list of titles related to the subject chosen from list ?

    • Prashant says:

      Welcome nikki,
      To send multiple value in autocomplete, we have to add an extra parameter to autocomplete function call.
      in my above example if you have a bropdown named dropdown_name, then the changes in autocomplete function call will goes like this :

      $(“#country”).autocomplete(“list.jsp”,{extraParams: { active : function() { return $(‘input[name=dropdown_name]’).val(); }} });

      and in JSP page you can get a request parameter as ‘active’

      combo=(String)request.getParameter(“active”);

      now you can use combo with query with AND clause.

  6. Rahul Gupta says:

    Thank you, I was in search of such a solution for so long.

  7. Carl says:

    Awesome post, works like a dream and i have learnt so much thankyou

  8. Saranya Jayaram says:

    Hi Prashant,
    I tried your code with SQL statement with the LIKE in the list.jsp page, but it is not working. And the didnt find the jquery-1.4.2.min.js file in the code I downloaded. But i downloaded it from somewhere else. Can u explain for what is the jquery-1.4.2.min.js used for. It will helpful if u provide a example for autocomplete with database.

    Thanks & Regard’s
    Saranya Jayaram

  9. Saranya Jayaram says:

    Hi Prashant,

    I found the jquery-1.4.2.min.js file. Didnt check it properly earlier..

    Regard’s
    Saranya Jayaram

  10. vijay says:

    HI PRASANTH,
    I HAVE TRIED U R EXAMPLE WHICH IS REALLY VERY NICE IN U R DEMO BUT IT IS NOT WORKING IN MY SIDE , I HV TRIED U R SUJJESTION ALSO 1) create JS folder in your application
    2) inside that folder paste jquery.autocomplete.js and jquery-1.4.2.min.js
    3) link js files from index.jsp(the file in which you want to insert auto textbox)
    4) in list.jsp (to display list from db) write code to print all list of data
    5) in index.jsp (auto textbox file) assign the list.jsp url in javascript autocomplete function

    jQuery(function(){
    $(“#country”).autocomplete(“list.jsp”);
    });

    BUT STILL AM NOT GETTING ANY RESULT IN MY COUNTRY TEXT BOX
    FILES USED:index.jsp……….jquery-1.4.2.min.js………jquery.autocomplete.js………list.jsp……..style.css IS AM MISSING ANY HTING HERE PLEASE FIGURE IT OUT ITS VERY URGENT REQUIREMENT TO ME PLEASE REPLY BACK

    • Prashant says:

      Hi Vijay,
      As you have told me, you have did everything correctly.
      I would like to suggest few issues that you should take care of
      1) the string you sent from index can be receive as (String)request.getParameter(“q”); in list.jsp
      2)Compare the folder and files placements. like .js files into JS directory, .css files into css directory etc.
      3)Jquery Script should be after the creation of the textbox.

      I hope this may help you. Once I suggest you to download my example and run it in your system.
      otherwise please send me your both JSP file. I hope i can check something in that.

      • vijay says:

        hi prasant,
        still it is not displaying any thing as per u r suggestion i hv placed 2 js files in js folder 1.jquery-1.4.2.min.js ……2.jquery.autocomplete.js and another one in css folder ie style.css file
        and 2 jsp files code is index.jsp

        Count :

        jQuery(function(){
        $(“#country”).autocomplete(“list.jsp”);
        });

        and list.jsp

      • Prashant says:

        please once download my example and run it.

  11. vijay says:

    hi prasant,
    still it is not displaying any thing as per u r suggestion i hv placed 2 js files in js folder 1.jquery-1.4.2.min.js ……2.jquery.autocomplete.js and another one in css folder ie style.css file
    and 2 jsp files code is index.jsp

    Count :

    jQuery(function(){
    $(“#country”).autocomplete(“list.jsp”);
    });

    and list.jsp

    <%

    String countries[] = {

    "Afghanistan",

    "Albania",

    "Algeria",

    "Andorra",

    "Angola",

    "Antigua and Barbuda",

    "Argentina",

    "Armenia",

    "Yemen",

    "Zambia",

    "Zimbabwe"

    };

    String query = (String)request.getParameter("q");

    System.out.println("1"+request.getParameterNames().nextElement());

    response.setHeader("Content-Type", "text/html");

    int cnt=1;

    for(int i=0;i=10)
    break;

    cnt++;

    }

    }

    %>

  12. vijay says:

    index.jsp

    Count :

    jQuery(function(){
    $(“#country”).autocomplete(“list.jsp”);
    });

    • Prashant says:

      that piece of code will be inside javascript tag after the creation of textbox.

      jQuery(function(){
      $("#country").autocomplete("list.jsp");
      });

      • sri says:

        Hi,

        if i want to retrive jsp page from another instance, what i have to do,please give detalis,the will one is useful for list.jsp in ourcontextroot, suppose if i am in another contextroot, but i want access the list.jsp , what i have to do , give me any suggestions
        $(“#country”).autocomplete(“list.jsp”);

      • Prashant says:

        once try to send the instance along with url
        list.jsp?value=
        I hope this may work.

  13. vijay says:

    yes it is inside only but is not displaying here i will try once again to paste it

    jQuery(function(){
    $(“#country”).autocomplete(“list.jsp”);
    });

  14. vijay says:

    yes i can but here i dnt have any attachments already i hv posted list.jsp code and i was tried to paste index .jsp but it is displaying only that jquery function , can u suggest me how can i send that files

    and thanks for u r great response

  15. vijay says:

    from my company id i dnt have access to send this files give me a 5 minutes i will send this from my personal id vijaybrathode@yahoo.com ,i will send u hole folder please check that it is very urgent for me but please reply here itself

  16. vijay says:

    please check u r id i hv sent one zip file vijaybrathode@yahoo.com is my personal id u can send files here

  17. vijay says:

    hai prasant
    did u get my mail is i made any mistake in this flow

  18. vijay says:

    thanks a lot prashant its working fine yes it is working in 1.1 version because in this they added
    * Added matchContains: “word” option, match only the start of words instead of everywhere
    * Fixed mustMatch to trigger result event when no match was found
    * Fixed the issue where an autocomplete was applied after the field had focus
    * Extended multiple complete to enable editing words not at the end of the field (doesn’t work in Opera)
    once again thanks a lot
    now am trying to connect with my database

  19. Saranya Jayaram says:

    Hi Prashant,
    I downloaded ur code and ran it eclipse but it was not working, then later I added the JSF capabilities in eclipse ur application worked fine. So i did the same with my project with database but again still it is not working. please help me it is very urgent..

    Thanks & Regard’s
    Saranya Jayaram

    • Prashant says:

      Hello Saranya,
      I think you are mistaken, while creating list. you don’t need to add any JSF capabilities.
      first just try with run the downloaded project. if it does not run then i have to look after it.

  20. vijay says:

    hi saranya jayaram can u send me list.jsp code

  21. vijay says:

    hi saranya jayaram can u send me list.jsp cod

  22. Saranya Jayaram says:

    Hi Vijay,
    here is the code..

  23. Saranya Jayaram says:
  24. Saranya Jayaram says:

    Vijay,
    I pasted it below.

  25. vijay says:

    am not getting ur code it is not displaying can u send me to this id

    prasad.shankarnarayana@asia.xchanging.com

    vijaybrathode@yahoo.com

  26. vijay says:

    hi prashant i need your help
    how to access two values in two different text box
    am able to display employee name from my database is there way to display corresponding employee id in other text box

  27. vijay says:

    hi saranya jayaram this is the code i used to fetch value from database

    <%
    //out.print("”+strAssigneeName+””);

    }
    }
    }
    catch(Exception e)
    {
    out.println(e);
    }

    %>

  28. Saranya Jayaram says:

    Hi Prashant,
    I just want to know whether there is any criteria that jquery works only in dynamic web project in eclipse. Or it works in a java project also in eclipse.

    With Regard’s
    Saranya Jayaram

    • Prashant says:

      Hi Saranya,
      Actually JQuery is a Web UI plugin. It may work with any web application that opens in browser.
      But not the stand alone project Like J2SE(AWT, SWING).

  29. Divya says:

    Hi Prashanth,

    I am looking for a solution for autocomplete with jquery, with struts 1.1.

    Can you please send me the code, i am unable to download it from the link given.

    Thanks,
    Divya

  30. Nitin Gupta says:

    Hi Prashant thanks for all your code i want to display an autocomplete listbox values from DB
    pls suggest me the code.

    • Prashant says:

      I have posted a suggestion to Mohammed on the comment list. Once try to follow it, I hope it may help you.
      otherwise write me where you are facing problem.

  31. niket says:

    Hey guys…please thank prashant sir for his extreme support to beginners like us….Thank you prashant sir!! great work…thanks for your support…keep helping us!!! :-) thanks a lot!!

    • Prashant says:

      thank you Niket for such a great comment.. by the way, Sir is too much for me.. I am just another student like you.

      • niket says:

        your blog helped me alot!! keep posting..i’ve learnt very much from this blog….thanks :) -niket

      • Prashant says:

        You are very much welcome, niket. I am really very happy that my post is helping someone to learn..

  32. niket says:

    Sir,
    i’m trying to develop a software which generally any shop keeper will use for the sake of billing in which we can get product name from the database and along with it he must be able to enter the quantity and amount of that product and later generate the bill/report for customer…can i get any reference which would help me doing the same…please help…i want to learn it..

    • Prashant says:

      Hello niket,
      First of all plz dont call me sir.. I am just a student like you.
      And about your project, Which technology you want to implement in that project.J2EE or J2SE.
      If you are confirm with the technology and the language, I will try to find some resource for you.

  33. hello prashant,
    am very new to jsp and javascript….could u plis explain to me expilicitly on how I can edit this code so that I get the data from postgresql database….I know this is too much but I’ll appreciate your help..you can email me at kamjugu@gmail.com

  34. R.Hemanand says:

    hi prasanth

    My name is Hemanand… just i need ur help do u have any idea about Hibernate framework.. if u having means plz help me…
    I am waiting ur reply…

    Thanks & Regards
    Hemanand

    • Prashant says:

      Hi Hemanand,
      Hibernate will be more easier in myeclipse. So i would like to suggest you to start hibernate in it.
      and about learning, I think this link will be very much useful tutorial for the beginner.
      If you get any problem, feel free to write.

  35. rajasekhar says:

    Hi prashanth,

    i am new one for jquery…. i am following ur guidelines to develop auto complete feature…
    My requirement is i have one drop down box and one text field in my jsp page… if i change any thing in my drop down box… the corresponding names will be displayed in text field …
    if i used ur hart coded values then functionality is working fine… with database i am not able to getting this functionality..
    i am giving some code to u based on this one i hope u can help me…

    function keyUp1()
    {
    var formObj = window.document.forms[0];
    var query = formObj.regionName.value;
    // alert(“query: “+query);
    <%– var query = –%>
    //System.out.println(“1″+request.getParameterNames().nextElement());
    var cnt=1;
    for(var i=0;i=10)
    break;
    cnt = cnt+1;

    }
    }
    }

    here i am getting these two alerts alert(“query: “+query); and alert(“temp1[i]: “+temp1[i]);
    suppose if i enter ‘a’ in text field … i am getting ‘a’ for this alert alert(“query: “+query);
    and Africa
    Antarctica
    Asia
    Australia for this alert alert(“temp1[i]: “+temp1[i]);

    But still i am not getting auto complete feature which is shown in ur demo part….

    can u help ASAP….

    thanks,
    raj

    • Prashant says:

      Hello Raj,
      Which version of Jquery you are using?

      • rajasekhar says:

        Hello Prashanth,

        I am using Jquery v1.6.2 and one more thing i am using this statement

        instead of taking tag for country….

        after that i am giving this statement

        jQuery(function(){
        /* $(“#regionName”).autocomplete(regionTypeList()); */
        $(“#regionName”).autocomplete(“Resources/jsp/ManageAsset/region.jsp”);
        regionTypeList();
        });

        if u wanna check my flow… give me ur gmail Id… i will send required files…

      • Prashant says:

        Please use JQuery v1.1, it will only work with jsp.

  36. Kapil says:

    hi Prashant,

    i try ur code, but it didnt get worked..

    I follow ur Steps wch u said earlier, but didnt get Output which i want..

    Please help m…

    Thanks in advance

  37. Kapil says:

    String query = (String)request.getParameter(“q”);

    can anyone explain meaning of above line we sending parameter as “q”…

    but getParameter function is receives id of textbox or label???

    thanks in advance..

  38. prudvi says:

    Thanks for your help ..
    I done the autocomplete thing after struggling 2 days…
    Here is the code i am attaching

    It isworking fine from fetching databse values

    list.jsp

    <%
    response.setContentType("text/html");
    int i=0;
    String str=request.getParameter("q");
    String countries[]=new String[15];
    System.out.println("String:::::::::"+str);
    try {
    String connectionURL = "jdbc:mysql://localhost:3306/project";
    Connection con;
    Class.forName("com.mysql.jdbc.Driver");
    // Get a Connection to the database
    con = DriverManager.getConnection(connectionURL, "root", "zeta");
    //Add the data into the database
    String sql = "SELECT prnam FROM acustomer WHERE prnam LIKE '"+str+"%' LIMIT 10";
    Statement stm = con.createStatement();
    stm.executeQuery(sql);
    ResultSet rs= stm.getResultSet();
    HashMap a1=new HashMap();
    while (rs.next ())
    {
    a1.put(++i,rs.getString("prnam"));
    }
    for(int j=1;j<=i;j++)
    {
    String x=a1.get(j).toString();
    countries[j] = x;
    System.out.println("hello"+countries[j]);
    }
    /*for(int j=1;i<=i;j++)
    {
    System.out.println("hello"+countries[j]);
    }*/
    response.setHeader("Content-Type", "text/html");
    int cnt=1;
    for(int j=0;i=10)
    break;
    cnt++;
    }
    }

    }
    catch(Exception e){
    out.println(“Exception is ;”+e);
    }
    %>

    auto.html

    Country :

    jQuery(function(){
    $(“#country”).autocomplete(“list.jsp”);
    });

    you need download jquery libraries

    regards
    prudvi raju

  39. Kapil says:

    for (int j = 1; j <= i; j++)
    {
    String x =(String) iter.next().toString();
    a[j] = x;
    out.println("hello" + a[j]);
    }

    i m getting error at line : String x =(String) iter.next().toString();

    Error is : An exception occurred processing JSP page /list.jsp

    iter is Iterator.

    Iterator having data of arraylist..

    can anyone help m???

    Thanks in advance

  40. Kapil says:

    Here is my List.jsp code :

    <%

    //String query = "9";//(String)request.getParameter("q");
    //System.out.println("1"+request.getParameterNames().nextElement());
    response.setHeader("Content-Type", "text/html");

    String name = null;
    name = "s";//(String) request.getParameter("q").trim();
    String a[] = new String[100];
    ArrayList b = new ArrayList();
    //out.print(name);
    Connection connection;
    Statement stmt = null;
    ResultSet rs = null;

    int cnt=0,i = 0;

    Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
    connection = DriverManager.getConnection("jdbc:odbc:ds", "sa", "gtssa@1234");
    stmt = connection.createStatement();
    rs = stmt.executeQuery("Select airline_name From airline_master ");

    Iterator iter = b.iterator();

    while (rs.next())
    {
    b.add( rs.getString(1));
    i++;
    }

    for (int j = 1; j

    Thanks in advance

    • Prashant says:

      Better you send me the source files to my mail.

      • Kapil says:

        Hey again sory ,
        but my Problem has been solved…

        dere is one question in my mind ,

        can we write code into servlet rather then jsp page…

        i tried from my side , but i didnt get output any output..

        Thanks in advance

      • Prashant says:

        please once check the Servlet from the browser by sending the the query string in url.
        if it works fine in browser, I think it should work with autocomplete too.

  41. Kapil says:

    my doubt is while using Servlet-Jsp or servlet-HTML,
    on click of Submit button on HTML or JSP page our request is send to Servlet…

    but in this case on the typing on textbox our Servlet hav 2 get called…

    i think its not possible in this senerio..

    if anyone had idea please share it…

    Thanks in Advance…

    • silentstar says:

      it is possible…just include the list.jsp code in servlet…and while calling give the path of the servlet instead of jsp.it works.

  42. silentstar says:

    Thanks a lot…!!!!!u made my day..! just implemented the same using MVC .n it works well :)

    • Kapil says:

      hey congrats !!!

      can u tell m in brief wat u have done in MVC pattern???

      because in my senerio there are 2 auto complete textbox,
      but dey vll not called at same time in same list.jsp page.

      i try for servlet but it didnt get work…

      Thanks in advance…..

  43. Ajay Kumar Srivastava says:

    Hi,

    how to implement countries flag image in corresponding list through this.

  44. KArthik says:

    hi,

    is it possible to get the values in the same jsp page ie (calling on the same page and getting the values on the same page itself)?? am getting the entire jsp page in the text box instead of the values..

    Thanks in advance..

  45. Martin says:

    Hi,
    Can i use your script in other language ?
    I want to use it in Thai .
    Thank in advance.

  46. Ansu says:

    hi,
    am new in jsp…could you please send me the jsp codings for autocomplete textbox for selecting places .

  47. Ansu says:

    Hi,
    Sry….i want the same codings for retreiving the datas from the database……plz send me the reply for this…its urgent.

  48. DHANESH V says:

    i want to insert username and image into database ,this is my code.i cant able to retrive upload images from database.if i will give select image from file where id=1.;it will diSplay image.but if i upload another image it will dispaly the same wheather i gave id=1.i want to retrieve newly uploaded image.SELECT IMAGE FROM FILE WHERE ID=”+ID+”;
    String username=request.getParameter(“username”);
    //out.println(username);
    String contentType = request.getContentType();
    if ((contentType != null) && (contentType.indexOf(“multipart/form-data”) >= 0))
    {out.println(“username”);
    DataInputStream in = new DataInputStream(request.getInputStream());
    int formDataLength = request.getContentLength();
    byte dataBytes[] = new byte[formDataLength];
    int byteRead = 0;
    int totalBytesRead = 0;
    while (totalBytesRead You have successfully upload the file by the name of:

    0){
    System.out.println(“Uploaded successfully !”);
    }
    else{
    System.out.println(“Error!”);
    }
    }
    catch(Exception e){e.printStackTrace();}

    %>

    <%

    try
    {
    //Retrieve the id of the product selected by the user
    //the product id is sent via the URL as a parameter
    int id = -1;

    String strid = request.getParameter("id");
    if(strid != null) {
    //Convert from string to int
    id = Integer.parseInt(strid);
    }

    //Load the database driver
    Class.forName("com.mysql.jdbc.Driver");
    //Create a connection to our database
    Connection con = DriverManager.getConnection("jdbc:mysql://localhost/datas", "root", "");
    //create an SQL statement
    PreparedStatement ps = con.prepareStatement("SELECT * FROM rows WHERE id=?");
    //set the ID to be the id above
    ps.setInt(1, id);
    //Execute and retrieve our result
    ResultSet rs1 = ps.executeQuery();

    if(rs1.next()){

    String imgLen = rs1.getString(1);

    int len = imgLen.length();

    byte [] rb = new byte[len];

    InputStream is = rs.getBinaryStream(1);

    int index=is.read(rb, 0, len);
    rs.close();

    response.reset();

    response.setContentType("image/jpg");

    response.getOutputStream().write(rb,0,len);

    response.getOutputStream().flush();

    }

    }

    catch (Exception e){

    e.printStackTrace();

    }
    }
    what is the mistake here,plz help me
    i want to retrieve images from database when i upload from some where.how can i do

  49. DHANESH V says:

    HI PRASANTH I want to retrive uploadedimages using jsp with mysql .could u plz send the code for inserting and retrivinguploading images

  50. DHANESH V says:

    hai prasanth i need ur help plz.can u sen me the code image uploading in jsp with mysql.actually i tried this code
    = 0))
    {out.println(“username”);
    DataInputStream in = new DataInputStream(request.getInputStream());
    int formDataLength = request.getContentLength();
    byte dataBytes[] = new byte[formDataLength];
    int byteRead = 0;
    int totalBytesRead = 0;
    while (totalBytesRead You have successfully upload the file by the name of:

    0){
    System.out.println(“Uploaded successfully !”);
    }
    else{
    System.out.println(“Error!”);
    }
    }
    catch(Exception e){e.printStackTrace();}

    %>

    this code is not working properly.in the retrieval part i used the code select images from rows whrer id=5″.in this way the images are displaying.but i want the code related to uploaded image.when i upload the image it can display without using id=3.PLZ HELP ME.

  51. DHANESH V says:

    actually that site is used to insert the image but i want to retrive image in jsp with mysql.could u plz send the code fir retieve image from mysql in jsp codeor any sites .
    = 0))
    {out.println(“username”);
    DataInputStream in = new DataInputStream(request.getInputStream());
    int formDataLength = request.getContentLength();
    byte dataBytes[] = new byte[formDataLength];
    int byteRead = 0;
    int totalBytesRead = 0;
    while (totalBytesRead You have successfully upload the file by the name of:

    0){
    System.out.println(“Uploaded successfully !”);
    }
    else{
    System.out.println(“Error!”);
    }
    }
    catch(Exception e){e.printStackTrace();}

    %>

  52. DHANESH V says:

    could u plz send the retriving the image uploading from database in JSP WITH MYSQL.
    PLZ HELP ME
    SELECT IMAGES FROM ROWS WHERE ID=1″.i tried this query but it shows the image when i give no id=1.but i want to retrive the uploaded image.plz help me

  53. DHANESH V says:

    could u plz send the retrival images from mysql using jspcode.
    first i upload the image it will insert into mysql using insert query and i wnt to retrieve images from mysql.SELECT IMAGES FROM tablename WHERE ID=1″.i tried this query.but it shows the when i give id=1 or some number.
    I WANT TO retrieve the image from mysql without using id.
    PLZ HELP ME.

  54. DHANESH V says:

    how to retrieve image from mysql.
    how to retrieve the uploaded image without specyfying the path and id no in jsp with mysql.
    i wnt to retrieve the image by using the select query where id=”id without specyfying the number.
    plz help me.could u plz send ot the code in jsp with mysql for retrieving the image without specyfying the path and id no.i wnt retrieve the uploaded image when id=”id;.

    • Prashant says:

      Sorry Dhanesh,
      I do not have any solution for this.. for me to retrieve single row or single data from database, we must have an unique field in where clause.

  55. Mithu says:

    Hi Prashanth,

    i want the codings for star rating to update and display from database…….please help me …..its very urgent…………………

  56. Mithu says:

    Hi,
    I want codings in jsp………..

  57. Narasimha says:

    Hi,

    In Jsp

    Javascript

    //Gets the browser specific XmlHttpRequest Object
    function getXmlHttpRequestObject() {
    if (window.XMLHttpRequest) {
    return new XMLHttpRequest();
    } else if (window.ActiveXObject) {
    return new ActiveXObject(“Microsoft.XMLHTTP”);
    } else {
    alert(“Your Browser Sucks!\nIt’s about time to upgrade don’t you think?”);
    }
    }
    // Our XmlHttpRequest object to get the auto suggest
    var searchReq = getXmlHttpRequestObject();
    var divPosition = 0;
    var divMaxPosition = -1;
    var prevPositoin = 0;
    var currentdivName = null;
    document.onclick=function hanldeClick(){
    try{
    if(currentdivName!=null)
    document.getElementById(currentdivName).innerHTML=”;
    document.getElementById(currentdivName).className = “noBorderClass”;
    divPosition = 0;
    divMaxPosition = -1;
    prevPositoin = 0;
    currentdivName = null;
    }catch (e) {}

    }
    // Called from keyup on the search textbox.
    // Starts the AJAX request.
    function searchSuggest(event, searchTextName, divName) {
    // alert(event.keyCode+” “+searchTextName+” “+divName);
    currentdivName=divName;

    if (event.keyCode == 40) {
    // suggestOut(null,”down”);
    suggestOver(null, “down”, divName);
    return;
    }
    if (event.keyCode == 38) {
    // suggestOut(null,”up”);
    suggestOver(null, “up”, divName);
    return;
    }
    if (event.keyCode == 13) {
    if (divMaxPosition > 0 && divPosition > 0)
    setSearch(document.getElementById(divName+”_”+divPosition).innerHTML,searchTextName, divName);
    return;
    }

    if (searchReq.readyState == 4 || searchReq.readyState == 0) {
    var searchText = escape(splitTextAfter(document.getElementById(searchTextName).value));
    //alert(searchText+” “+searchTextName)
    //fieldname=searchTextName;
    searchReq.open(“GET”, ‘searchSuggest?search=’ + searchText + ‘&fieldname=’ +searchTextName, true);
    searchReq.onreadystatechange = function handleSearchSuggest() {
    if (searchReq.readyState == 4) {
    var ss = document.getElementById(divName);
    ss.innerHTML = ”;
    var str = searchReq.responseText.split(“\n”);
    if (str.length > 1)
    ss.className = “borderClass”;
    else
    ss.className = “noBorderClass”;

    divMaxPosition = str.length – 1;
    divPosition = 0;
    prevPositoin = 0;
    // alert(divMaxPosition+”loop”);
    for (i = 0; i < str.length – 1; i++) {

    var suggest = '’ + str[i] + ”;
    ss.innerHTML += suggest;
    }
    }
    }
    searchReq.send(null);
    }
    }
    // Called when the AJAX response is returned.

    // Mouse over function
    function suggestOver(div_value, eventId, divName) {
    try {
    // alert(divMaxPosition+””+divPosition)
    if (divMaxPosition > 0) {
    if (eventId == “down”) {
    if (divPosition divMaxPosition – 1)
    divPosition = 1;
    else
    divPosition++;

    div_value = document
    .getElementById(divName + “_” + divPosition);
    }
    if (eventId == “up”) {
    // alert(divPosition+” u “+divMaxPosition);
    if (divPosition 0)
    suggestOut(document
    .getElementById(divName + “_” + prevPositoin));
    // alert(div_value.id)
    try{
    div_value.className = ‘suggest_link_over';
    }catch(ex){}
    divId = div_value.id;
    prevPositoin = divId.substring(divId.lastIndexOf(“_”) + 1,
    divId.length);
    divPosition = prevPositoin;
    }
    } catch (e) {

    }

    }
    // Mouse out function
    function suggestOut(div_value) {
    try{
    div_value.className = ‘suggest_link';
    }catch (e) {}

    }
    // Click function
    function setSearch(value, searchTextName, divName) {
    searchTextRef = document.getElementById(searchTextName);
    searchTextRef.value = splitTextBefore(searchTextRef.value) + value + “,”;
    document.getElementById(divName).innerHTML = ”;
    document.getElementById(divName).className = “noBorderClass”;
    }
    function splitTextBefore(totalText) {
    return totalText.substring(0, totalText.lastIndexOf(“,”) + 1);
    }
    function splitTextAfter(totalText) {
    return totalText
    .substring(totalText.lastIndexOf(“,”) + 1, totalText.length);
    }

    searchSuggest.java

    String searchText = request.getParameter(“search”);
    String fieldname=request.getParameter(“fieldname”);

    if(fieldname.equals(“country”)){
    preparedStatement = connection.prepareStatement(“Select DISTINCT TOP(10) COUNTRY from DOCUMENT_LOCATION where COUNTRY like ?”);
    preparedStatement.setString(1,searchText+”%”);
    resultSet = preparedStatement.executeQuery();
    while(resultSet.next()){
    buffer.append(resultSet.getString(“COUNTRY”));
    buffer.append(“\n”);
    }
    resultSet.close();
    preparedStatement.close();
    }

    I hope this may help you.

  58. DHANESH V says:

    hai prasanth,thanks
    i have another doubt
    this is my table structure.i want to insert image logo and ROUTEMAP with text in mysql.how can do that.u have any idea.PLZ TELL ME THE ROUTEMAP,,HOW TO MAKE THAT.
    Table structure for table trainer

    Column

    Type

    Null

    Default

    consumer_id

    varchar(10)

    No

    user_id

    varchar(30)

    No

    password

    varchar(30)

    No

    name

    varchar(30)

    No

    phone

    varchar(15)

    No

    fax

    varchar(15)

    No

    mobile

    varchar(15)

    No

    email_id

    varchar(20)

    No

    address

    varchar(250)

    No

    landmark

    varchar(250)

    No

    type

    varchar(50)

    No

    skill1

    varchar(20)

    No

    skill2

    varchar(20)

    No

    skill3

    varchar(20)

    No

    skill4

    varchar(20)

    No

    skill5

    varchar(20)

    No

    short_description

    varchar(50)

    No

    full_description

    varchar(250)

    No

    mode_trainingid

    varchar(30)

    No

    strength

    varchar(20)

    No

    experience

    varchar(10)

    No

    established_year

    varchar(10)

    No

    contact_person1

    varchar(30)

    No

    contact_person2

    varchar(30)

    No

    contact_person1_phone

    varchar(30)

    No

    contact_person2_phone

    varchar(15)

    No

    contact_person1_email

    varchar(30)

    No

    contact_person2_email

    varchar(30)

    No

    career_guidance

    varchar(30)

    No

    lab

    varchar(30)

    No

    mentor_service

    varchar(30)

    No

    logo

    blob

    No

    url

    varchar(30)

    No

    video_link1

    longblob

    No

    video_link2

    longblob

    No

    routemap_text

    text

    No

    routemap_image

    blob

    No

    routemap_google

    longblob

    No

    weekday_hours

    varchar(20)

    No

    saturday_hours

    varchar(20)

    No

    sunday_hours

    varchar(20)

    No

  59. sharath says:

    Hi prashant,

    i am not getting the list because data is not fetching from the data base so, the list is not displaying. i add the code below please revert me as soon as possible. i am in bottleneck position,

    list.jsp

    <%
    try{
    Connection con;
    Statement stmt;
    ResultSet rs;
    String host="jdbc:mysql://localhost:3306/books";
    //books is the database name
    String uName="root";
    String uPass="root";
    con=DriverManager.getConnection(host,uName,uPass);
    stmt=con.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_UPDATABLE);

    /* copy the countries name in the table "country" with a field name countries
    countrieslist =
    "Afghanistan",
    "Albania",
    "Algeria",
    "Andorra",
    "Angola",
    "Antigua and Barbuda",
    "Argentina",
    "Armenia",
    "Australia",
    "Austria",
    "Azerbaijan",
    "Bahamas",
    "Bahrain",
    "Bangladesh",
    "Barbados",
    "Belarus",
    "Belgium",
    "Belize",
    "Benin",
    "Bhutan",
    "Bolivia",
    "Bosnia and Herzegovina",
    "Botswana",
    "Brazil",
    "Brunei",
    "Bulgaria",
    "Burkina Faso",
    "Burundi",
    "Cambodia",
    "Cameroon",
    "Canada",
    "Cape Verde",
    "Central African Republic",
    "Chad",
    "Chile",
    "China",
    "Colombi",
    "Comoros",
    "Congo (Brazzaville)",
    "Congo",
    "Costa Rica",
    "Cote d'Ivoire",
    "Croatia",
    "Cuba",
    "Cyprus",
    "Czech Republic",
    "Denmark",
    "Djibouti",
    "Dominica",
    "Dominican Republic",
    "East Timor (Timor Timur)",
    "Ecuador",
    "Egypt",
    "El Salvador",
    "Equatorial Guinea",
    "Eritrea",
    "Estonia",
    "Ethiopia",
    "Fiji",
    "Finland",
    "France",
    "Gabon",
    "Gambia, The",
    "Georgia",
    "Germany",
    "Ghana",
    "Greece",
    "Grenada",
    "Guatemala",
    "Guinea",
    "Guinea-Bissau",
    "Guyana",
    "Haiti",
    "Honduras",
    "Hungary",
    "Iceland",
    "India",
    "Indonesia",
    "Iran",
    "Iraq",
    "Ireland",
    "Israel",
    "Italy",
    "Jamaica",
    "Japan",
    "Jordan",
    "Kazakhstan",
    "Kenya",
    "Kiribati",
    "Korea, North",
    "Korea, South",
    "Kuwait",
    "Kyrgyzstan",
    "Laos",
    "Latvia",
    "Lebanon",
    "Lesotho",
    "Liberia",
    "Libya",
    "Liechtenstein",
    "Lithuania",
    "Luxembourg",
    "Macedonia",
    "Madagascar",
    "Malawi",
    "Malaysia",
    "Maldives",
    "Mali",
    "Malta",
    "Marshall Islands",
    "Mauritania",
    "Mauritius",
    "Mexico",
    "Micronesia",
    "Moldova",
    "Monaco",
    "Mongolia",
    "Morocco",
    "Mozambique",
    "Myanmar",
    "Namibia",
    "Nauru",
    "Nepal",
    "Netherlands",
    "New Zealand",
    "Nicaragua",
    "Niger",
    "Nigeria",
    "Norway",
    "Oman",
    "Pakistan",
    "Palau",
    "Panama",
    "Papua New Guinea",
    "Paraguay",
    "Peru",
    "Philippines",
    "Poland",
    "Portugal",
    "Qatar",
    "Romania",
    "Russia",
    "Rwanda",
    "Saint Kitts and Nevis",
    "Saint Lucia",
    "Saint Vincent",
    "Samoa",
    "San Marino",
    "Sao Tome and Principe",
    "Saudi Arabia",
    "Senegal",
    "Serbia and Montenegro",
    "Seychelles",
    "Sierra Leone",
    "Singapore",
    "Slovakia",
    "Slovenia",
    "Solomon Islands",
    "Somalia",
    "South Africa",
    "Spain",
    "Sri Lanka",
    "Sudan",
    "Suriname",
    "Swaziland",
    "Sweden",
    "Switzerland",
    "Syria",
    "Taiwan",
    "Tajikistan",
    "Tanzania",
    "Thailand",
    "Togo",
    "Tonga",
    "Trinidad and Tobago",
    "Tunisia",
    "Turkey",
    "Turkmenistan",
    "Tuvalu",
    "Uganda",
    "Ukraine",
    "United Arab Emirates",
    "United Kingdom",
    "United States",
    "Uruguay",
    "Uzbekistan",
    "Vanuatu",
    "Vatican City",
    "Venezuela",
    "Vietnam",
    "Yemen",
    "Zambia",
    "Zimbabwe"
    };*/

    String query = (String)request.getParameter("q");
    String sql="select countries from country where countries like '"+query+"%'";
    rs=stmt.executeQuery(sql);
    rs.last();
    int length=rs.getRow();
    response.setHeader("Content-Type", "text/html");
    int cnt=1;

    if(rs.first()){
    for(int i=0;i=10)
    break;
    cnt++;
    rs.next();
    }

    }
    }
    else{
    out.println(“country name not in the database”);
    }

    %>

  60. sharath says:

    Hi prashanth,

    Please send me the code regarding jquery tree view in jsp using data base please any one help me .

    Regards
    sharath

  61. DHANESH V says:

    hi prasanth,i want to split two different datas in one text box and insert into mysql in jsp.i already got the code for splitting the two datas in one text box.now i want to insert that dats in mysql in two different rows.
    this is the code for SPLITTING THE TWO DATAS.NOW HOW TO INSERT THAT DATAS IN TWO DIFFERENT ROWS IN MYSQL.PLZ HELP

    // For: http://www.webdeveloper.com/forum/showthread.php?t=244715

    String.prototype.trim = function() {
    return(this.replace(/^\s+/,”).replace(/\s+$/,”));
    }
    var queryStringInfo = [];
    function validate() {
    var temp = document.getElementById(‘info’).value.trim();
    var queryStringInfo = temp.split(‘ ‘);
    var wcnt = 0;
    var str = ”;
    for (var i=0; i<queryStringInfo.length; i++) {
    wcnt++; str += 'Word #'+wcnt+' '+queryStringInfo[i].trim()+'\n'; }
    alert(str);
    if (wcnt != 2) { alert('Invalid input: 2 words only!'); return false; }
    return true;
    }

  62. sanjana says:

    Hi,
    Can some one please help me with my requirement plz.
    My requirement is every name should be clickable.When ever user will click on any the country name,it should redirect user to a URL.:
    eg:If user selects “USA”,he should get redirected to http://www.us.com(This URL will be caculated from server side code.)
    Thanks,
    Sanjana

  63. bona says:

    hi,

    can u please tell me from where to download the two js file please ……

  64. DHANESH V says:

    how to encrypt and decrypt in jsp.i need the code regarding encrypted datas in to decrypt.

  65. DHANESH V says:

    acually i want to create encrypted and decrypted datas in jsp.how it can access from jsp.can u give me code for encrypted and decryped datas in jsp.plz help me.

  66. DHANESH V says:

    can u help me.actually, i want to insert videos in php using mysql.how to insert videos in php using mysql.please help me.
    plz help me that.

  67. Nishantha says:

    Can this integrate with the database values?.Is it possible to retrieve values from Oracle Db and auto complete text box using that values? thanks

    • Prashant says:

      Yes obviously. Actually it all depends on what you fetch in to the JSP page, same thing gonna display into the text list.
      So I guess, you can retrive the Oracle data into JSP, rt?

  68. DHANESH V says:

    hi prasahanth ,how to retrieve and split the datas from database mysql using php and display
    plz help me to retrieve and display and split the inserted data from mysql using php

  69. Alex says:

    hii men thanks for all,but i have a question how i made a autocomplete whith my mysql db in jsp?
    pd:sorri for mi bad english i am of south america
    thankss

    • Prashant says:

      in this example I am using array of countries.. but you have to behave similar with the database received data.
      so that the result set will be the array to display into the autocomplete.

  70. joe says:

    Very good content

  71. DHANESH V says:

    how to retrieve datas from mysql using next and previous button in php.
    actually i need the source code for retrieving datas from mysql in php .
    example
    name department
    hari ,kiran hr
    jagan,lal accounts

    if we click next button it shows hari in hr and again we click next button it shows kiran in hr like that indually it shows
    plz help me that.

  72. DHANESH V says:

    how to retrieve datas from mysql using next and previous button in php.
    actually i need the source code for retrieving datas from mysql in php .
    example
    name department
    hari ,kiran hr
    jagan,lal accounts

    if we click next button it shows hari in hr and again we click next button it shows kiran in hr like that indually it shows
    plz help me that.

  73. Dehan says:

    Hi,

    i have one question, is there way to populate the full list (the dropdown list with all the data) when clicking on button when there is nothing entered in the text box.

    Thank you

    Dejan

  74. DHANESH V says:

    how to swap three rows using php with mysql.actually i tried this code but it is not working properly.the code will be given below
    query(‘SELECT id,day,month,year,location,venue FROM TopTips ORDER BY id ASC LIMIT 0,1000′);

    // Get an array containing the results.
    // Loop for each item in that array
    echo ‘Top Tips';

    while ($row =mysql_fetch_array($result)){

    echo ”;
    echo ”;
    echo $row[‘day’];
    echo ”;
    echo ”;
    echo $row[‘month’];
    echo ”;
    echo ”;
    echo $row[‘year’];
    echo ”;
    echo ”;
    echo $row[‘location’];
    echo ”;
    echo ”;
    echo $row[‘venue’];
    echo ”;
    echo ”;
    echo ‘EDIT /';
    echo ”;
    echo ”;
    echo ‘DELETE‘;

    echo ‘ ‘;
    echo ‘ ‘;
    echo ”;

    echo ”;
    echo ‘‘;
    echo ”;

    echo ”;
    echo ”;

    }
    ?>

  75. swaminathan says:

    hi prashant ,
    last few days i was trying to make a auto-complete extender in my project and my code showed only error after that i seen your code ,its nice and running a superbly ,thank u

  76. 21AhmadNasr8 says:

    Hi prashant,
    Thanks for your useful post.

  77. DHANESH V says:

    how to retrieve registraction form datas from textfile in php.

  78. DHANESH says:

    how to create datepicker in php.can u explain in full detail

  79. Said says:

    hello it is probable to use this plugin in key-value paire if yes please tell how to proceed

  80. said says:

    hi Prashant thank you for this incredible plugint help me a lot,
    but i want to know if this plugin supports id/value (if i click on value the id wil be showed on textbox ) is that possible ? and how can i proceed thank you ;)

  81. Logos says:

    Hello Prashant, how if I want to autocomplete more than one textbox only using one database query search?
    For example I have a database containing country name and the capitals. and in the webpage I have two textboxes to be filled, one by the country name, and the other one by the corresponding capital. How to fill both textboxes after one of them have been auto-completed?
    Thank you

  82. leema says:

    Hello Prashant,i have tried a lot bt why ths code is nt working properly???do i need to connect db fr all field??

  83. venkatesan says:

    Hello prasanth i used your code for passing additional parameters to get the auto complete feature.

    when i select some products in a dropdown, and after that when i type some letters in the text box, it should display the corresponding items for the dropdown selected.

    reference:
    ————————————————————————————————
    $(“#country”).autocomplete(“list.jsp”,{extraParams: { active : function() { return $(‘input[name=dropdown_name]‘).val(); }} });

    ————————————————————————————————
    and u asked to retrieve the value with “active” variable. when i received i am getting only null value.

    in the “dropdown_name” i replaced my dropdown control name say “nodeName”.

    how to resolve it. please guide.

  84. Nikita says:

    hello..
    please help me about auto complete text example..
    I have tried your example, but still it is not working.. please help

    • Prashant says:

      Hi Nikita,
      Please use same version of jquery.autocomplete.js. It will work.

      • Nikita Dandekar says:

        Hello, Thanks.. But I have wanted it urgently,
        I have used source method of autocomplete function in jquery.
        And It will work fine..

        Here, I have used the code.

        $(“#tags”).autocomplete({
        source: function(request, response) {
        var matches = $.map(list, function(tag) {
        if (tag.toUpperCase().indexOf(request.term.toUpperCase()) === 0) {
        return tag;
        }
        });
        response(matches);
        }
        });
        });

        Again thanks your reply..
        I will use same version of autocomplete and will try it other way too.

  85. Sarath Babu says:

    Hi Prasanth,
    Your code is not working for jquery verion 1.9 . please help me .

  86. alekhya says:

    hi prashant ur code is not working for me . will u pls help me ?

  87. alekhya says:

    can u send me the proper list.jsp file?? pls its urgent

  88. alekhya says:

    yeahh i used same .js files. Still not working. I think problem is with list.jsp

  89. alekhya says:

    <%
    String countries[] = { "Afghanistan",
    "Albania",
    "Algeria",
    "Andorra",
    "Angola",
    "Antigua and Barbuda",
    "Argentina",
    "Armenia",
    "Yemen",
    "Zambia",
    "Zimbabwe"
    };

    String query = (String)request.getParameter("q");
    // System.out.println("1"+request.getParameterNames().nextElement());
    response.setHeader("Content-Type", "text/html");
    int cnt=1;
    for(int i=0;i=10)
    break;
    cnt++;
    }
    }
    %>

    this is the code i am using

  90. hi prashanth plz help me
    i want the code for insert delete and edit datas are displayed in same page in php or ajax.plz help its urgent

  91. hello prasanth plz help me plz
    how to display images from mysql in php.its urgent could u plz help me

  92. Majid says:

    hi
    i Tried Your Example But It Is Not Working,
    I Think Its Unable To Connect List.jsp File.

  93. Wally says:

    Hello,
    I got everything working and I even connect it to database. I have 2 text boxes that one cascading the values of the other… I got that working too :-)… but I ran in to an issue with cache I believe… Here is the issue:
    1st time search on box 1 selected a value and box 2 select a value… works
    2nd time search on something else selected a value and box 2 CONTAIN results from 1st and second search…
    Is there any way when search on box one to reset the values of 2nd box using keyup function…
    I do not want to use $(“#tag”).val(”); I need to reset the result list on 1st search.

    Hope you get my explanation…
    Tnx in adv.

  94. anisha says:

    Hi prashant sir………in the above eg(Autocomplete Textbox in JSP)…………where i get style.css,jquery-1.4.2.min.js and ,jquery.autocomplete.js

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Follow

Get every new post delivered to your Inbox.

Join 188 other followers

%d bloggers like this: