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.
1 Attachment(s)
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"> Asset Identification Number <font color="red">*</font>:</td>
<td align="left" id="asset" >
<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