I am currently working on a database project that involves a webpage with 5 textboxes. One of these textboxes needs to display values from the database when it is in focus. I have the JavaScript and AJAX code to retrieve the data, but I am facing difficulties in displaying the retrieved values in the textbox. Despite several attempts, I have been unsuccessful in achieving this.
Could someone assist me in resolving this issue?
Here is the code snippet I am working with:
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];
}
Currently, I am utilizing the showData function as shown above. In order to implement autocomplete functionality, I need to make some modifications here:
input type="text" id="vendor_name" name="vendor_name" onkeyup="showData();