Expiring Today—Celebrate National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Error:  Cannot assign to a function result

Posted on 2004-04-30
7
Medium Priority
?
649 Views
Last Modified: 2008-02-07
I have the following ASP code:
<%
...
Response.Write "<script language='javascript'> " & vbCrLf
Response.Write "var arrayData = new Array();" & vbCrLf
               do while not rs.eof
      ... code that loops through a recordset and adds the data to th area...
                Response.Write "arrayData(" & intCnt & ").... recordset data
   
                intCnt = intCnt + 1
      rs.MoveNext
      loop

Response.Write "</script>"

%>

Everything writes out correctly, but I get a Cannot assign to a function result error at the line that writes out "var arrayData = new Array();" and I do not know what could be causing the error.

Any help would be appreciated.  Thanks.

Kirk
0
Comment
Question by:CapnCrnch
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 5
7 Comments
 
LVL 63

Expert Comment

by:Zvonko
ID: 10960371
This line looks suspect:

Response.Write "arrayData(" & intCnt & ").... recordset data


Rewrite it to:

  Response.Write "arrayData[" & intCnt & "] = ".... recordset data";


0
 
LVL 63

Expert Comment

by:Zvonko
ID: 10960386
Sorry, you need apostrophes:

   Response.Write "arrayData[" & intCnt & "] = '".... recordset data"'; " & vbCrLf

Do you see them?



0
 
LVL 63

Accepted Solution

by:
Zvonko earned 500 total points
ID: 10960413
Also a good trich to avoid array counter is to use this:

Response.Write "<script language='javascript'> " & vbCrLf
Response.Write "var arrayData = new Array();" & vbCrLf
              do while not rs.eof
                   Response.Write "arrayData[arrayData.length] = '".... recordset data"'; " & vbCrLf

You see the Array.length trick?

0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 

Author Comment

by:CapnCrnch
ID: 10960455
Thanks Zvonko.  Appreciate the help.
0
 
LVL 63

Expert Comment

by:Zvonko
ID: 10960471
You are welcome.
0
 
LVL 46

Expert Comment

by:Sjef Bosman
ID: 10960574
You can do better, by initializing the Array immediately, then you wouldn't need the counter.

Response.Write "<script language='javascript'> " & vbCrLf
Response.Write "var arrayData = new Array(" & vbCrLf
              do while not rs.eof
                   Response.Write "'" & .... recordset data & "', " & vbCrLf
              loop
Response.Write ");" & vbCrLf
0
 
LVL 63

Expert Comment

by:Zvonko
ID: 10961935
Good idea.
Only small problem is the last coma.
But that problem can be solved by adding one last empty element and removing it afterwards.
Like this:

Response.Write "<script language='javascript'> " & vbCrLf
Response.Write "var arrayData = new Array(" & vbCrLf
              do while not rs.eof
                   Response.Write "'" & .... recordset data & "', " & vbCrLf
              loop
Response.Write " '');" & vbCrLf
Response.Write "arrayData.length--;" & vbCrLf


You see?



0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I've been trying to accomplish this for a while and it just struck me yesterday how to accomplish this task. I have done searches all over the internet looking for ways to email pages from my applications and finally I have done it!!! Every single s…
Nothing in an HTTP request can be trusted, including HTTP headers and form data.  A form token is a tool that can be used to guard against request forgeries (CSRF).  This article shows an improved approach to form tokens, making it more difficult to…
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

730 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question