[Javascript] Reading values into an array

Rodney Myers rodney at aflyingstart.net
Tue Jul 15 08:09:57 CDT 2003


Alan,

It may be easier to first declare the array and then write the data line 
by line.

{pseudo code only for serverside}


<script language="JavaScript">
<!--
var my_values=new Array();

[set a server side counter to value zero  n=0]

[write lines of data for each value in the recordset]

my_values[ write value of n here ] = "[write name of nth image here]";
[Increment value of n]

[loop back until whole recordsset written]

// -->
</script>

Client side result:

<script language="JavaScript">
<!--

var my_values=new Array();
my_values[0]="photo1.jpg";
my_values[1]="photo2.jpg";
my_values[2]="photo3.jpg";

// -->
</script>

hth

Rodney



Alan Easton wrote:

>Hello All,
> 
>I have the results of an ASP recordset that I would like to read into a
>Javascript array. My recordset only returns 3 records, so I need to end up
>with a javascript 1D array similar to:
> 
>var my_values=new Array("photo1.jpg","photo2.jpg","photo3.jpg")
> 
>Where photo1.jpg, photo2.jpg, photo3.jpg are the 3 records that have been
>returned in my recordset.
> 
>Does any one have any idea on how I would go about doing this. I realise it
>is tricky going from ASP recordsets to 1D javascript arrays, but I need some
>guidance.
> 
>Any suggestions or links to further information would be much appreciated.
> 
>Thanks,
> 
>Alan...
>  
>
>------------------------------------------------------------------------
>
>_______________________________________________
>Javascript mailing list
>Javascript at LaTech.edu
>https://lists.LaTech.edu/mailman/listinfo/javascript
>  
>

-- 
PS. If you have to answer routine email queries 
from your sites or mailings then you will find 
the simple-to-use BizAutomator invaluable.
http://www.BizAutomator.co.uk












More information about the Javascript mailing list