I am doing a database project. I have a webpage where I have 5 text fields. In one of the text fields, when it is in focus, I have to show the user the values ββpresent in the database. I know how to extract using javascript and AJAX, but I cannot display the resulting values ββin a text box. I tried a lot, but could not get it.
Can someone help me with this?
The code is as follows:
function showData(){ xmlHttp=GetXmlHttpObject() var id=document.getElementById("vendor_name").value; var url="ftc_id.jsp"; url=url+"?vendor_name="+id; xmlHttp.onreadystatechange=stateChanged xmlHttp.open("GET",url,true) xmlHttp.send(null); } function stateChanged(){ if(xmlHttp.readyState==4 || xmlHttp.readyState=="complete"){ var showdata = xmlHttp.responseText; var strar = showdata.split(":"); if(strar.length>1){ var strname = strar[1]; document.getElementById("vendor_address").value= strar[1]; document.getElementById("vendor_contact_no").value= strar[2]; document.getElementById("currency").value= strar[3]; document.getElementById("po_value_rs").value= strar[4]; }
Map me m using the showData line as above. For autocomplete, I have to make some changes here:
input type="text" id="vendor_name" name="vendor_name" onkeyup="showData();
source share