BradEdwards
Technical User
I have a form, let's say for simplicity sake, with 2 input fields
<input type="text" name="empNum" onchange="empName.value=GetUserName(this.value)">
<input type="text" name="empName">
Now i have a db that stores all the employee information which is linked to an employee number. What i want to do is when the employee types in their employee number the GetUserName() function accesses the database and returns the Name of the employee.
Here is my function:
<script>
function GetUserName(objEmpNum)
{
<%
Dim rs, strSQL
strSQL = "Select (strFirstName + ' ' + strLastName) AS FullName, intEmpNum from tblEmployees WHERE intEmpNum=79"
set rs=Server.CreateObject("ADODB.Recordset"
objconn.execute "Use dbGeneral"
rs.open strSQL, objconn
%>
return "<% =rs("FullName"
%>";
}
</script>
Right now it works, but as you can see I'm selecting the data based on the EmpNum. So right now any number I put in the EmpNum field on the form it comes back with the name of employee number 79. What I would like to know how to do is create a select statement based on the EmpNum value passed through from the form. From what i've read since ASP is server side and Javascript is client side, I can't send a JavaScript variable to ASP code. What other way can I use to create my select statement?? Thanks.
<input type="text" name="empNum" onchange="empName.value=GetUserName(this.value)">
<input type="text" name="empName">
Now i have a db that stores all the employee information which is linked to an employee number. What i want to do is when the employee types in their employee number the GetUserName() function accesses the database and returns the Name of the employee.
Here is my function:
<script>
function GetUserName(objEmpNum)
{
<%
Dim rs, strSQL
strSQL = "Select (strFirstName + ' ' + strLastName) AS FullName, intEmpNum from tblEmployees WHERE intEmpNum=79"
set rs=Server.CreateObject("ADODB.Recordset"
objconn.execute "Use dbGeneral"
rs.open strSQL, objconn
%>
return "<% =rs("FullName"
}
</script>
Right now it works, but as you can see I'm selecting the data based on the EmpNum. So right now any number I put in the EmpNum field on the form it comes back with the name of employee number 79. What I would like to know how to do is create a select statement based on the EmpNum value passed through from the form. From what i've read since ASP is server side and Javascript is client side, I can't send a JavaScript variable to ASP code. What other way can I use to create my select statement?? Thanks.