Forums
This topic is locked
Passing Javascript variable to asp
17 Jan 2004 01:13:38 Touti P posted:
I have a form field that once entered calls a function to verify if that PID already exists in the database. In the javascript function, the parameter is the PID to query. I need to pass that variable to asp in order to perform the query. How do I do just that? Here's what I have so far.Response.Write("<script type='text/javascript' language='javascript'>"
Response.Write("function PIDExists(field)) {"
Response.Write("var PID=document.getElementById(field).value"
Dim theVariable
theVariable= ??????
Dim rsVerifyPID
Set rsVerifyPID = Server.CreateObject("ADODB.Recordset"
rsVerifyPID.ActiveConnection = VerifyPID
rsVerifyPID.Source = "SELECT * FROM Sometable WHERE PID=" & theVariable & ";"
rsVerifyPID.CursorType = 0
rsVerifyPID.LockType = 2
rsVerifyPID.CursorLocation = 2
rsVerifyPID.Open()
strSQL_numRows = 0
If NOT rsVerifyPID.EOF Then
Response.Write("alert('PID already exists')"
Response.Write("} </script>"
End If
rsVerifyPID.close
Set rsVerifyPID = nothing