longmatch
Programmer
- Nov 1, 2001
- 406
Dear All:
I just got a piece of code and tried to make it work in my program. there is runtime error "expected "(" on line 22". But when I counted "(" agaist "
", I found the number of them are the same. I know the problem is in the function definition. Unfortunately I do not know how to fix. The program is for a dynamically-linked listbox.
Thanks,
Haijun
The code is
<!--#include file="ClssfdPage.asp"-->
<HTML>
<HEAD>
<META NAME="GENERATOR" Content="Microsoft Visual Studio 6.0">
<TITLE></TITLE>
</HEAD>
<BODY>
<form name=f1>
<%
Set rsX = Server.CreateObject("ADODB.Recordset"
sQuery = "SELECT Category.Category, Procedurelist.Procedure, " & _
"Category.CategoryID AS ManuID, Procedurelist.ProcedureID AS ProcedureID " & _
"FROM Procedurelist INNER JOIN Category " & _
"ON Procedurelist.CategoryID = Category.CategoryID " & _
"ORDER BY Category.Category, Procedurelist.Procedure"
rsX.Open sQuery, objConn, adOpenForwardOnly, _
adLockReadOnly, adCmdText
If rsX.EOF Then
Response.Write "No Category.<BR>"
Else
' write the Category listbox...
Response.Write "<SELECT NAME=""Category"" SIZE=15" & _
" ONCHANGE=""manuselected(this);"" >"
' write the entry code for the javascript...
sJavaScript = "function manuselected(elem){" & vbCrlf & _
"for (var i = document.f1.Procedure." & _
"options.length; i >= 0; i--){" & vbCrlf & _
"document.f1.Procedure.options = null;" & _
vbCrlf
' loop through the recordset...
Do Until rsX.EOF
' is this a new Category?
If sLastCategory <> rsX("Category"
Then
' if so, add an entry to the first listbox
sLastCategory = rsX("Category"
Response.Write "<OPTION VALUE=" & rsX("ManuID"
& _
">" & sLastCategory & "</OPTION>"
' and add a new section to the javascript...
sJavaScript = sJavaScript & "}" & vbCrlf & _
"if (elem.options[elem.selectedIndex].value==" & _
rsX("ManuID"
& "
{" & vbCrlf
End If
' and add a new Procedure line to the javascript...
sJavaScript = sJavaScript & _
"document.f1.Procedure.options[document." & _
"f1.Procedure.options.length] = new Option('" & _
rsX("Procedure"
& "','" & rsX("ProcedureID"
& _
"');" & _
vbCrlf
rsX.MoveNext
Loop
' finish the Category listbox...
Response.Write "</SELECT>"
' create the Procedures listbox...
Response.Write "<SELECT NAME=""Procedure"" SIZE=15>"
Response.Write "<OPTION>[none currently selected]</OPTION>"
Response.Write "</SELECT>"
' put the last line on the javascript...
' and write it out...
sJavaScript = sJavaScript & vbCrlf & "}" & vbCrlf & _
"}" & vbCrlf
Response.Write "<SCRIPT LANGUAGE=""JavaScript"">" & vbCrlf
Response.Write sJavaScript & vbCrlf & "</SCRIPT>" & vbCrlf
End If
rsX.Close
Set rsX = Nothing
%>
</form>
</BODY>
</HTML>
I just got a piece of code and tried to make it work in my program. there is runtime error "expected "(" on line 22". But when I counted "(" agaist "
Thanks,
Haijun
The code is
<!--#include file="ClssfdPage.asp"-->
<HTML>
<HEAD>
<META NAME="GENERATOR" Content="Microsoft Visual Studio 6.0">
<TITLE></TITLE>
</HEAD>
<BODY>
<form name=f1>
<%
Set rsX = Server.CreateObject("ADODB.Recordset"
sQuery = "SELECT Category.Category, Procedurelist.Procedure, " & _
"Category.CategoryID AS ManuID, Procedurelist.ProcedureID AS ProcedureID " & _
"FROM Procedurelist INNER JOIN Category " & _
"ON Procedurelist.CategoryID = Category.CategoryID " & _
"ORDER BY Category.Category, Procedurelist.Procedure"
rsX.Open sQuery, objConn, adOpenForwardOnly, _
adLockReadOnly, adCmdText
If rsX.EOF Then
Response.Write "No Category.<BR>"
Else
' write the Category listbox...
Response.Write "<SELECT NAME=""Category"" SIZE=15" & _
" ONCHANGE=""manuselected(this);"" >"
' write the entry code for the javascript...
sJavaScript = "function manuselected(elem){" & vbCrlf & _
"for (var i = document.f1.Procedure." & _
"options.length; i >= 0; i--){" & vbCrlf & _
"document.f1.Procedure.options = null;" & _
vbCrlf
' loop through the recordset...
Do Until rsX.EOF
' is this a new Category?
If sLastCategory <> rsX("Category"
' if so, add an entry to the first listbox
sLastCategory = rsX("Category"
Response.Write "<OPTION VALUE=" & rsX("ManuID"
">" & sLastCategory & "</OPTION>"
' and add a new section to the javascript...
sJavaScript = sJavaScript & "}" & vbCrlf & _
"if (elem.options[elem.selectedIndex].value==" & _
rsX("ManuID"
End If
' and add a new Procedure line to the javascript...
sJavaScript = sJavaScript & _
"document.f1.Procedure.options[document." & _
"f1.Procedure.options.length] = new Option('" & _
rsX("Procedure"
"');" & _
vbCrlf
rsX.MoveNext
Loop
' finish the Category listbox...
Response.Write "</SELECT>"
' create the Procedures listbox...
Response.Write "<SELECT NAME=""Procedure"" SIZE=15>"
Response.Write "<OPTION>[none currently selected]</OPTION>"
Response.Write "</SELECT>"
' put the last line on the javascript...
' and write it out...
sJavaScript = sJavaScript & vbCrlf & "}" & vbCrlf & _
"}" & vbCrlf
Response.Write "<SCRIPT LANGUAGE=""JavaScript"">" & vbCrlf
Response.Write sJavaScript & vbCrlf & "</SCRIPT>" & vbCrlf
End If
rsX.Close
Set rsX = Nothing
%>
</form>
</BODY>
</HTML>