[thelist] Solution to - why does this code produce error at load?
Brian Delaney
brian.delaney at mccmh.net
Fri Apr 8 06:36:23 CDT 2005
The reason I was getting the error is because the value for strName was
not interpreted as a string.
I am building a javascript statement in asp. The correct syntax is:
response.write "agencynamearray[" & intCount & "] = """ & strName &""";"
The wrong syntax:
response.write "agencynamearray[" & intCount & "] = " & strName & chr(13)
goodday
BD
Brian Cummiskey wrote:
> 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
>
>
>
>
*
*
*
This message, including any attachments, is intended solely for the use of the named recipient(s) and may contain confidential and/or priveleged information. Any unauthorized review, use, disclosure or distribution of this communication(s) is expressly prohibited. If you are not the intended recipient, please contact the sender by reply e-mail and destroy any and all copies of the original message.
More information about the thelist
mailing list