944,131 Members | Top Members by Rank

Ad:
Nov 29th, 2004
0

how to pass a array from asp to javascript

Expand Post »
how to pass a array from asp to javascript
Similar Threads
Reputation Points: 10
Solved Threads: 0
Newbie Poster
Deepa is offline Offline
19 posts
since Nov 2004
Jan 5th, 2005
0

Re: how to pass a array from asp to javascript

Quote originally posted by Deepa ...
how to pass a array from asp to javascript
You might want to use the join method in Jscript to populate your client side javascript. Use the join like this on an array called cars:

JavaScript / DHTML / AJAX Syntax (Toggle Plain Text)
  1. <%
  2. var sep = "','";
  3. var carlist = cars.join(sep);
  4. %>

Note: Make sure that you include the appropriate quotes in the sep string. Its very difficult to illustrate here but you need a doublequote then singlequote then a comma then a single quote and then a double quote (with no spaces in between): "','"

Then take the list that was created and populate your clientside script. I will create the clientside javascript array called fooCars:

JavaScript / DHTML / AJAX Syntax (Toggle Plain Text)
  1. <script language="JavaScript">
  2. fooCars = new Array('<%=carlist%>');
  3. </script>

Again make sure that you surround your variable call in ASP by single quotes.

This should do it.
Reputation Points: 10
Solved Threads: 1
Newbie Poster
Javaknight is offline Offline
10 posts
since Dec 2004

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in JavaScript / DHTML / AJAX Forum Timeline: a weird Javascript error
Next Thread in JavaScript / DHTML / AJAX Forum Timeline: How to have two clocks on one php forum?





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC