Click here to Skip to main content
15,886,026 members
Please Sign up or sign in to vote.
2.15/5 (3 votes)
See more:
I need to create dynamical arrays, for example yesrs will be fetched from database like ex:2014 ,2013. I need this two years create an array dynamically like year2014[],year2013[] and after this i need to add values in year2014[23,23,45],year2013[32,34,54].

Please Find my code bellow.
How can i write code for creating dynamical arrays and pull the data from
database and push the values in dynamic values .

My code :
JavaScript
var xmlDoc = $parseXML(response.d);
        var xml = window.jquery(xmlDoc);
        var customers = xml.find("sampledatayearwise");
        var datavars=[];        
        $.each(customers, function ()              
        {    
           for(var i=0; i<years.length;>        { 
             datavars.push("year" + years[i]);
           }
        }


i need this format: result
year2014[23,43,43];
year2013[34,45,66];

Please Help me....
Posted
Updated 26-Jun-14 19:17pm
v3
Comments
Sergey Alexandrovich Kryukov 27-Jun-14 1:15am    
Everything in Javascript is dynamic, including arrays, which are actually the associative containers. It has nothing to do with jQuery (and your sample code is only remotely related to jQuery). Your problem is unclear.
—SA
pramodgorityala 27-Jun-14 1:26am    
please give me suggestion about how to create dynamic arrays
Sergey Alexandrovich Kryukov 27-Jun-14 1:35am    
a[1] = "some data";
a[10] = "some other piece of data";
//...

Dynamically; no need to allocate anything, etc. Indices don't have to be continuous, can be any objects, not only integers.
And so on...

—SA
SRS(The Coder) 27-Jun-14 1:18am    
From where years came from any code for its declaration ?
pramodgorityala 27-Jun-14 1:24am    
am getting years from database

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900