I'm having trouble passing a variable from ASP/VBScript to a JavaScript function.
I'm trying to pass the var_URL to the openwin() function. But keep getting a "Line: 22 Error: 'var_URL' is undefined" in the ASP portion of the code (points to <body> line).
Below is my code: Any steering in the right direction would be appreciated.
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<title>Test</title>
<script language="Javascript">
function openwin(varURL){
var Features;
var URL = '<%=var_URL%>';
//Browser features
Features="toolbar=no,location=no,directories=no,status=no, menubar=no,scrollbars=no,resizable=yes,width=375,height=200";
var OpenWindow = window.open(URL,"",Features);
}
</script>
</head>
<body>
<%
Dim oConn, sConnStr, sTable, qByLastName
sTable = "Users"
sConnStr = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\Inetpub\ Security Info=False"
set oConn = Server.CreateObject("ADODB.Connection"
oConn.Open sConnStr
set oRS = Server.CreateObject("ADODB.Recordset"
qByLastName = "SELECT ID, LNAME, FNAME, EXT FROM Users ORDER BY LNAME, FNAME;"
oRS.Open qByLastName, oConn, , , adCmdTable
response.write "<table>"
do while not oRS.EOF
var_URL = "more.asp?dbase=" & sTable & "&id=" & oRS("ID"
response.write "<tr><td><a href='#' onclick='openwin(var_URL)'>" & oRS("LNAME"
& "</a></td></tr>"
oRS.MoveNext
loop
Response.Write "</TABLE>"
oRS.Close
oConn.Close
set oRS = Nothing
%>
</body>
</html>
I'm trying to pass the var_URL to the openwin() function. But keep getting a "Line: 22 Error: 'var_URL' is undefined" in the ASP portion of the code (points to <body> line).
Below is my code: Any steering in the right direction would be appreciated.
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<title>Test</title>
<script language="Javascript">
function openwin(varURL){
var Features;
var URL = '<%=var_URL%>';
//Browser features
Features="toolbar=no,location=no,directories=no,status=no, menubar=no,scrollbars=no,resizable=yes,width=375,height=200";
var OpenWindow = window.open(URL,"",Features);
}
</script>
</head>
<body>
<%
Dim oConn, sConnStr, sTable, qByLastName
sTable = "Users"
sConnStr = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\Inetpub\ Security Info=False"
set oConn = Server.CreateObject("ADODB.Connection"
oConn.Open sConnStr
set oRS = Server.CreateObject("ADODB.Recordset"
qByLastName = "SELECT ID, LNAME, FNAME, EXT FROM Users ORDER BY LNAME, FNAME;"
oRS.Open qByLastName, oConn, , , adCmdTable
response.write "<table>"
do while not oRS.EOF
var_URL = "more.asp?dbase=" & sTable & "&id=" & oRS("ID"
response.write "<tr><td><a href='#' onclick='openwin(var_URL)'>" & oRS("LNAME"
oRS.MoveNext
loop
Response.Write "</TABLE>"
oRS.Close
oConn.Close
set oRS = Nothing
%>
</body>
</html>