User Name Password Register
DaniWeb IT Discussion Community
All
What is DaniWeb IT Discussion Community?
You're currently browsing the JavaScript / DHTML / AJAX section within the Web Development category of DaniWeb, a massive community of 375,208 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 2,291 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our JavaScript / DHTML / AJAX advertiser: Lunarpages Web Hosting
Views: 18428 | Replies: 1
Reply
Join Date: Nov 2004
Posts: 19
Reputation: Deepa is an unknown quantity at this point 
Rep Power: 4
Solved Threads: 0
Deepa Deepa is offline Offline
Newbie Poster

how to pass a array from asp to javascript

  #1  
Nov 29th, 2004
how to pass a array from asp to javascript
AddThis Social Bookmark Button
Reply With Quote  
Join Date: Dec 2004
Location: Washington DC
Posts: 10
Reputation: Javaknight is an unknown quantity at this point 
Rep Power: 4
Solved Threads: 1
Javaknight's Avatar
Javaknight Javaknight is offline Offline
Newbie Poster

Solution Re: how to pass a array from asp to javascript

  #2  
Jan 5th, 2005
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:

<%
     var sep = "','";
     var carlist = cars.join(sep);
%>

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:

<script language="JavaScript">
     fooCars = new Array('<%=carlist%>');
</script>

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

This should do it.
Reply With Quote  
Reply

Only community members can participate in forum threads. You must register or log in to contribute.

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 

DaniWeb JavaScript / DHTML / AJAX Marketplace
Thread Tools Display Modes

Similar Threads
Other Threads in the JavaScript / DHTML / AJAX Forum

All times are GMT -4. The time now is 2:53 am.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC