Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 3 of 3

Thread: autocomplete using ajax

  1. #1
    Junior Member
    Join Date
    May 2011
    Posts
    5
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default autocomplete using ajax

    Hi guys,
    I am new to ajax and java technologies. From last 2 months i m working in java and other technologies.
    I want to write code for autocomplete textbox in ajax using struts. i
    i want fetch values frm database using struts.
    in jsp page i hv to write ajax and related function of javaascript and in struts page i hv to write database connection & other related things.
    Plz help me..
    Its urgent!!


  2. #2
    Super Moderator Json's Avatar
    Join Date
    Jul 2009
    Location
    Warrington, United Kingdom
    Posts
    1,274
    My Mood
    Happy
    Thanks
    70
    Thanked 156 Times in 152 Posts

    Default Re: autocomplete using ajax

    Hello, what bit of your whole requirement is it that you have a problem doing, it sounds like you want help to do the whole thing and as far as I can see its databases, struts, javascript and jsp all in one, try starting some of it your self and once you get stuck tell us what exactly you are stuck on as that's more likely to give you a positive response.

    At the moment I don't really know where to start helping you, sorry.

  3. #3
    Junior Member
    Join Date
    May 2011
    Posts
    5
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: autocomplete using ajax

    Hi,
    i tried ajax code in jsp and struts. i m getting data frm DB but it is not displaying in textbox(displaying below textbox).
    below my code in jsp page:
    function showData(value){
    var name1;

    xmlHttp=GetXmlHttpObject();
    var url="<%=request.getContextPath()%>/beforeModifyAsset.do?parameter=autoCmplete";
    url=url+"&asset="+value;

    xmlHttp.onreadystatechange=stateChanged ;
    xmlHttp.open("GET",url,true)
    xmlHttp.send(null)
    }

    function stateChanged() {
    if(xmlHttp.readyState==4 || xmlHttp.readyState=="complete"){
    var showdata = xmlHttp.responseText;
    document.getElementById("mydiv").innerHTML= showdata;
    }
    }
    function GetXmlHttpObject(){
    var xmlHttp=null;
    try {
    xmlHttp=new XMLHttpRequest();
    }
    catch (e) {
    try {
    xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
    }
    catch (e) {
    xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
    }
    }
    return xmlHttp;
    }
    <body class="background" id="bodycontent" onload="assetId()">
    <html:form action="/beforeModifyAsset.do">
    <br>
    <center>
    <span class="pageHeading"><bean:message key="LS0305" /></span>
    </center>
    <br>
    <logic:messagesPresent>
    <table width="450" border="0" cellpadding="0" cellspacing="0" align="center">
    <html:messages id="error">
    <tr>
    <td align="center" width="95%" class="BodyTextMed">
    <font color="red">
    <li>
    <span class="alertMsgs"><bean:write name="error" /></span>
    </li>
    </font>
    </td>
    </tr>
    </html:messages>
    </table>
    </logic:messagesPresent>
    <logic:messagesPresent message="true">
    <table border="0" width="450" cellpadding="0" cellspacing="0" align="center">
    <html:messages id="message" message="true">
    <tr>
    <td align="center" align="center">
    <font color="red">
    <li>
    <span class="alertMsgs"><bean:write name="message" /></span>
    </li>
    </font>
    </td>
    </tr>
    </html:messages>
    </table>
    </logic:messagesPresent>
    <table width="60%" align="center" class="table">
    <tr>
    <td>
    <table width="98%" align="center" cellSpacing=0 cellPadding=0 border=0 id="bodycontent" >
    <tr>
    <td align="left" class="td">&nbsp;&nbsp;Asset Identification Number&nbsp;<font color="red">*</font>:</td>
    <td align="left" id="asset" >&nbsp;
    <html:text property="assetId" onkeyup="showData(this.value);"></html:text>
    <div id="mydiv"></div>
    </td>
    </tr>
    <tr>

    Note: i want to display in textbox similar to google search.
    plz help me.. wat to do next
    Attached Images Attached Images

Similar Threads

  1. Review of a new MVC framework for writting portlet for Ajax Portal
    By Sergei Sokolov in forum Web Frameworks
    Replies: 1
    Last Post: March 15th, 2011, 08:44 AM
  2. Hello (4 books, 1 MVC framework and Ajax Portal)
    By Sergei Sokolov in forum Member Introductions
    Replies: 1
    Last Post: March 15th, 2011, 05:26 AM
  3. Autocomplete over telnet connection
    By April in forum Java Networking
    Replies: 6
    Last Post: June 17th, 2010, 08:58 AM
  4. JSP freezes after AJAX call !!
    By java_freek in forum JavaServer Pages: JSP & JSTL
    Replies: 1
    Last Post: April 16th, 2010, 10:31 AM
  5. How to use Ajax concepts in jsp page(for view) with servlet?
    By sundarjothi in forum JavaServer Pages: JSP & JSTL
    Replies: 1
    Last Post: July 8th, 2009, 06:20 AM