Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

expected ")" error

Status
Not open for further replies.

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=&quot;ClssfdPage.asp&quot;-->

<HTML>
<HEAD>
<META NAME=&quot;GENERATOR&quot; Content=&quot;Microsoft Visual Studio 6.0&quot;>
<TITLE></TITLE>
</HEAD>
<BODY>
<form name=f1>
<%
Set rsX = Server.CreateObject(&quot;ADODB.Recordset&quot;)
sQuery = &quot;SELECT Category.Category, Procedurelist.Procedure, &quot; & _
&quot;Category.CategoryID AS ManuID, Procedurelist.ProcedureID AS ProcedureID &quot; & _
&quot;FROM Procedurelist INNER JOIN Category &quot; & _
&quot;ON Procedurelist.CategoryID = Category.CategoryID &quot; & _
&quot;ORDER BY Category.Category, Procedurelist.Procedure&quot;
rsX.Open sQuery, objConn, adOpenForwardOnly, _
adLockReadOnly, adCmdText
If rsX.EOF Then
Response.Write &quot;No Category.<BR>&quot;
Else
' write the Category listbox...
Response.Write &quot;<SELECT NAME=&quot;&quot;Category&quot;&quot; SIZE=15&quot; & _
&quot; ONCHANGE=&quot;&quot;manuselected(this);&quot;&quot; >&quot;
' write the entry code for the javascript...
sJavaScript = &quot;function manuselected(elem){&quot; & vbCrlf & _
&quot;for (var i = document.f1.Procedure.&quot; & _
&quot;options.length; i >= 0; i--){&quot; & vbCrlf & _
&quot;document.f1.Procedure.options = null;&quot; & _
vbCrlf
' loop through the recordset...
Do Until rsX.EOF
' is this a new Category?
If sLastCategory <> rsX(&quot;Category&quot;) Then
' if so, add an entry to the first listbox
sLastCategory = rsX(&quot;Category&quot;)
Response.Write &quot;<OPTION VALUE=&quot; & rsX(&quot;ManuID&quot;) & _
&quot;>&quot; & sLastCategory & &quot;</OPTION>&quot;
' and add a new section to the javascript...
sJavaScript = sJavaScript & &quot;}&quot; & vbCrlf & _
&quot;if (elem.options[elem.selectedIndex].value==&quot; & _
rsX(&quot;ManuID&quot;) & &quot;){&quot; & vbCrlf
End If
' and add a new Procedure line to the javascript...
sJavaScript = sJavaScript & _
&quot;document.f1.Procedure.options[document.&quot; & _
&quot;f1.Procedure.options.length] = new Option('&quot; & _
rsX(&quot;Procedure&quot;) & &quot;','&quot; & rsX(&quot;ProcedureID&quot;) & _
&quot;');&quot; & _
vbCrlf
rsX.MoveNext
Loop
' finish the Category listbox...
Response.Write &quot;</SELECT>&quot;
' create the Procedures listbox...
Response.Write &quot;<SELECT NAME=&quot;&quot;Procedure&quot;&quot; SIZE=15>&quot;
Response.Write &quot;<OPTION>[none currently selected]</OPTION>&quot;
Response.Write &quot;</SELECT>&quot;
' put the last line on the javascript...
' and write it out...
sJavaScript = sJavaScript & vbCrlf & &quot;}&quot; & vbCrlf & _
&quot;}&quot; & vbCrlf
Response.Write &quot;<SCRIPT LANGUAGE=&quot;&quot;JavaScript&quot;&quot;>&quot; & vbCrlf
Response.Write sJavaScript & vbCrlf & &quot;</SCRIPT>&quot; & vbCrlf
End If
rsX.Close
Set rsX = Nothing
%>

</form>

</BODY>
</HTML>
 
sometimes that problem is caused by stray quotes(usually when ppl use apostrophes within a string and FORGET to escape them)

sadly, as my name suggests, i forget the escape seq for that, and you gave too much code for me to possibly find the right line, err, quickly. This may help you out though. make sure you don't use any ' or &quot; within a string.
 
javascript's escape character is
so,
var escapedQuote = &quot;\&quot;&quot;;

perhaps this will help...

this error can also be caused by imbalanced curly braces {}

======================================

if (!succeed) try();
-jeff
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top