Click here to Skip to main content
15,888,340 members
Please Sign up or sign in to vote.
5.00/5 (1 vote)
See more:
Hello guys,

how to get arrarylist in javascript and it's all element in asp.net application

please help me

Thank you in advance!
Posted

 
Share this answer
 
Comments
Sumit Kumar Singh India 14-Dec-11 3:22am    
thank you nice link!
Abhinav S 14-Dec-11 3:56am    
You are welcome.
function ArrayList()
{
  this.array = new Array();
  this.add = function(obj){
    this.array[this.array.length] = obj;
  }
  this.iterator = function (){
    return new Iterator(this)
  }
  this.length = function (){
    return this.array.length;
  }
  this.get = function (index){
    return this.array[index];
  }
  this.addAll = function (obj)
  {
    if (obj instanceof Array){
      for (var i=0;i<obj.length;i++)>
      {
        this.add(obj[i]);
      }
    } else if (obj instanceof ArrayList){
      for (var i=0;i<obj.length();i++)>
      {
        this.add(obj.get(i));
      }
    }
  }
}

function Iterator (arrayList){
  this.arrayList;
  this.index = 0;
  this.hasNext = function (){
    return this.index < this.arrayList.length();
  }
  this.next = function() {
    return this.arrayList.get(index++);
  }
}

Or See this link http://www.koders.com/javascript/fid32ECAD6CCE114257D4044549E14ABCEC1332DF7E.aspx[^]
another way,-
var myArray = new Array();
myArray.push("string 1");
myArray.push("string 2");
 
Share this answer
 

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