473,320 Members | 1,955 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

Create Dynamic Arrays

Hi,

Is there a way in javascript to create Dynamic arrays or arrays on
fly.
Something Like:
var "ptsgN"+sd = new Array();

Here sd is incrementing by 1.

I have lots of data that I am putting in arrays.
I dont have the exact no.
i dont want to do that:
var ptsgN1 = new Array();
var ptsgN2 = new Array();
var ptsgN3 = new Array();
var ptsgN4 = new Array();
.....

Any Advice.
Oct 16 '08 #1
4 5400
Sunny wrote:
Hi,

Is there a way in javascript to create Dynamic arrays or arrays on
fly.
Something Like:
var "ptsgN"+sd = new Array();

Here sd is incrementing by 1.

I have lots of data that I am putting in arrays.
I dont have the exact no.
i dont want to do that:
var ptsgN1 = new Array();
var ptsgN2 = new Array();
var ptsgN3 = new Array();
var ptsgN4 = new Array();
....

Any Advice.
This would work:

for(var i=0;i<9;i++)
window["ptsgN"+i]=[];

[] is the same as new Array()
Oct 16 '08 #2
On Thu, 16 Oct 2008 12:53:50 -0700 (PDT), Sunny <su**********@gmail.comwrote:
>Hi,

Is there a way in javascript to create Dynamic arrays or arrays on
fly.
Something Like:
var "ptsgN"+sd = new Array();

Here sd is incrementing by 1.

I have lots of data that I am putting in arrays.
I dont have the exact no.
i dont want to do that:
var ptsgN1 = new Array();
var ptsgN2 = new Array();
var ptsgN3 = new Array();
var ptsgN4 = new Array();
Two dimensional array?

Grant.
--
http://bugsplatter.id.au
Oct 16 '08 #3
On Oct 16, 4:05 pm, Stevo <n...@mail.invalidwrote:
Sunny wrote:
Hi,
Is there a way in javascript to create Dynamic arrays or arrays on
fly.
Something Like:
var "ptsgN"+sd = new Array();
Here sd is incrementing by 1.
I have lots of data that I am putting in arrays.
I dont have the exact no.
i dont want to do that:
var ptsgN1 = new Array();
var ptsgN2 = new Array();
var ptsgN3 = new Array();
var ptsgN4 = new Array();
....
Any Advice.

This would work:

for(var i=0;i<9;i++)
window["ptsgN"+i]=[];

[] is the same as new Array()
Thanks Stevo,
It worked...
Oct 16 '08 #4
Sunny wrote:
Is there a way in javascript to create Dynamic arrays or arrays on
fly.
In ECMAScript implementations, arrays are dynamic by default.
Something Like:
var "ptsgN"+sd = new Array();

Here sd is incrementing by 1.
Array object references can be elements of arrays.
[...]
Any Advice.
RTFM, finally. (And why not employ a spellchecker before posting?)

<http://jibbering.com/faq/>
PointedEars
--
Prototype.js was written by people who don't know javascript for people
who don't know javascript. People who don't know javascript are not
the best source of advice on designing systems that use javascript.
-- Richard Cornford, cljs, <f8*******************@news.demon.co.uk>
Oct 16 '08 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: learnfpga | last post by:
Here is a little code I wrote to add the numbers input by the user.....I was wondering if its possible to have the same functionality without using dynamic arrays.....just curious..... ...
2
by: assgar | last post by:
Hi Developemnt on win2003 server. Final server will be linux Apache,Mysql and PHP is being used. I use 2 scripts(form and process). The form displays multiple dynamic rows with chechboxs,...
23
by: sandy | last post by:
I need (okay, I want) to make a dynamic array of my class 'Directory', within my class Directory (Can you already smell disaster?) Each Directory can have subdirectories so I thought to put these...
4
by: hobbes992 | last post by:
Howdy folks, I've been working on a c project, compiling using gcc, and I've reached a problem. The assignment requires creation of a two-level directory file system. No files have to be added or...
19
by: Dongsheng Ruan | last post by:
with a cell class like this: #!/usr/bin/python import sys class Cell: def __init__( self, data, next=None ): self.data = data
2
by: poojapo | last post by:
hi all, can you help me with a code to create dynamic arrays in perl?
4
by: singleb | last post by:
I've tryed to something lik this and got "Object reference not set to an instance of an object." Dim myarr(,) As String myarr(0, 0) = "aaaa" myarr(0, 1) = "bbbb" myarr(1, 0) = "cccc" myarr(1,...
5
by: plsHelpMe | last post by:
How to create dynamic javascript arrays using dojo toolkits Hello frens, I am in a big trouble. My objective is: I am having some categories shown by differnent radio buttons, on the click of...
2
by: =?Utf-8?B?SHVzYW0=?= | last post by:
Hi EveryBody: I am using vb.net 2005 and the following code trying to create varible at runtime: For n=1 to 4 dim v+n.tostring(n) as double Next n the resone behaind using the previous...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.