I am using AJAX to return a name from the database so that the user inputting data knows that they input the correct register # (a unique number for each person in the db).
Here is the interface code,
code for showName function,
And the ASP page that writes out the name,
Now, I would like to use the same function to return a different column from the database (CliEPI) and place it in a hidden textbox.
How can I do this? I tried response.writing the CliEPI out with the name, and then splitting it in javascript, but my javascript knowledge is not too good, and I was unable to sort it out.
Thanks,
Drew
Here is the interface code,
Code:
<label for="RegNo" class="required">First Name:</label>
<input type="text" id="RegNo" onBlur="showName(this.value,'Name1','RegNo1','EPI1')">
<input name="RegNo1" type="hidden" value="">
Name: <span id="Name1" class="boldtext"></span>
<br>
<label for="AggRegNo" class="required">Second Name:</label>
<input type="text" id="AggRegNo" onBlur="showName(this.value,'Name2','RegNo2','EPI2')">
<input name="RegNo2" type="hidden" value="">
Name: <span id="Name2" class="boldtext"></span>
<br>
code for showName function,
Code:
function showName(RegNo,ctlName,ctlName2,ctlName3){
if (RegNo.length==0){
document.getElementById(ctlName).innerHTML=""
document.form1[ctlName2].value = RegNo;
return
}
var xmlHttp = GetXmlHttpObject();
var url = "//swvtc06/swvtc/db/cli/shared/AJAX_getresidentname.asp";
url += "?RegNo="+RegNo;
url += "&sid="+Math.random();
if (!xmlHttp){
alert ("Browser does not support HTTP Request")
return
}
xmlHttp.onreadystatechange=function(){
if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete"){
document.getElementById(ctlName).innerHTML=xmlHttp.responseText;
//document.getElementById(ctlName2).Value=RegNo
document.form1[ctlName2].value = RegNo;
}
};
xmlHttp.open("GET", url, true);
xmlHttp.send(null);
}
function GetXmlHttpObject(){
var objXMLHttp=null;
if (window.XMLHttpRequest){
objXMLHttp=new XMLHttpRequest();
}else if (window.ActiveXObject){
objXMLHttp=new ActiveXObject("Microsoft.XMLHTTP");
}
return objXMLHttp;
}
And the ASP page that writes out the name,
Code:
Dim rsName
Dim rsName_numRows
Set rsName = Server.CreateObject("ADODB.Recordset")
rsName.ActiveConnection = MM_CliCore_STRING
rsName.Source = "SELECT RegNo, CliFName, CliMM, CliLName, CliEPI, CliDOB FROM tblClients WHERE CliActive = 1 AND RegNo = " & Request.QueryString("RegNo")
'Response.Write(rsName.Source)
rsName.CursorType = 0
rsName.CursorLocation = 2
rsName.LockType = 1
rsName.Open()
rsName_numRows = 0
If rsName.BOF Or rsName.EOF Then
Response.Write("No Resident With Register Number Provided")
Else
rsName.Fields.Item("CliFName").Value & " " & rsName.Fields.Item("CliMM").Value & ". " & rsName.Fields.Item("CliLName").Value)
End If
Now, I would like to use the same function to return a different column from the database (CliEPI) and place it in a hidden textbox.
How can I do this? I tried response.writing the CliEPI out with the name, and then splitting it in javascript, but my javascript knowledge is not too good, and I was unable to sort it out.
Thanks,
Drew