[thelist] Frustrated - why does this code produce error at load?

Brian Cummiskey Brian at hondaswap.com
Tue Apr 5 14:32:43 CDT 2005


Brian Delaney wrote:
> thanks for that, but now the error has moved to the line when I populate 
> the array - this line:
> 
>    response.write "agencynamearray[" & intCount & "] = " & strName & ";" 
> & chr(13)
> 
> same error -  expected ';'
> 
> thanks

here's the code you pasted:

function getAgencyName(frmIncident)
        {
.
.
.
            response.write "agencynamearray[" & intCount & "] = " & 
strName & ";" & chr(13)            response.write "agencycodearray[" & 
intCount + 1 & "] = " & strCode & ";" & chr(13)
.
.
.
} //end function


now, i don't know if it just didn't copy correctly...  but if you start 
another response.write statement on the same line, it will trigger an 
asp error.

here's what i would do to test:

break out the asp.

run your sql command.
copy/paste your results into the JS loop and see what you come up with. 
  there's a good chance your sql isn't formatting correctly-- and with 
the hard coded ";" hanging out in there, i can see it being a problem.

also, try using & VbCrLf or & "\r\n" instead of & Chr(13), at least to 
test.  i'm not sure if JS will pick up on it the same way or not.


a quick fill in yields the following:

response.write "agencynamearray[0] = TheNameHere;" & chr(13) 
response.write "agencycodearray[0] = TheCodeHere;" & chr(13)

Now, throw that in your JS loop with the asp assumed processed...


function getAgencyName(frmIncident)
        {
        var agencynamearray() = new Array;
        var agencycodearray() = new Array;

	agencynamearray[0] = TheNameHere;
	agencycodearray[0] = TheCodeHere;
	
	for (i=0; i<1; i++)
         {
         	if (frmIncident.txtAgencyCode.value == agencycodearray[i])
                    {                          							 
frmIncident.txtAgencyName.Value = agencynamearray[i];
                 } //end if
         } //end for
} //end function
	



Some things to check are the arrary strings.  you may be missing a set 
of quotes.


response.write "agencynamearray[0] = TheNameHere;" & chr(13)
might need to be:
response.write "agencynamearray[0] = ""TheNameHere"";" & chr(13)
or something to that extent.

its kinda hard to test with out the DB data to play with.  give it a shot.

-Brian






More information about the thelist mailing list