Asp.net programming we consider all important topic for knowledge about controls,web Services, JSON, Ajax, database, and interview related Question. In this Asp.net and sql server tutorial blog we give many examples of jquery as like How Play YouTube Video in Your Asp.net Website by URL, How to Play YouTube Videos in Asp.net by using Jquery , Jquery Change div background on mouseover in asp.net , JQuery UI Datepicker (Calendar) etc.

Tuesday, July 29, 2014

Create Javascript Array List

How to Create Javascript Array List

Create Javascript Array List in html page by using javascript programming is easy task.As we know that Js is a client side scripting language.In this site you get all Example Related to the Asp.net Programming.In Asp.net development we need many time this code.

Declare Create Array list by javascript.

For Creating a JavaScript Array list here we make page_load event on page and in this event  write javascript code.Js Execute at client end so it is fast.
For this first create a variable in here with Name myArraylist.Arraylist is a class in javascript ,now we create a object of Arraylist.

dim myArraylist=New ArrayList

here dim is a keyword.

<script  runat="server">
Sub Page_Load
if Not Page.IsPostBack then
   dim myArraylist=New ArrayList
   myArraylist.Add("Norway") // Adding first element in array list.
   myArraylist.Add("Sweden") // Adding Second element in array list
   myArraylist.Add("France") // Adding Thred element in array list
   myArraylist.Add("Italy")
   myArraylist.TrimToSize()
   myArraylist.Sort()
   
end if
end sub

</script>


Display Array list by javascript

Once Array list is create the we need to display this list by javascript language.
sub displayMessage(s as Object,e As EventArgs)

for( dim i=0;i < myArraylist.length;i++)
alert(myArraylist[i] +"at index of"+ i);

end sub


Description of Example of Array list by javascript :

In this Example we want to create a list of countries in javascript Array list,First we create array list object then we insert element in this array one by one.After Createing this we want to display this Array list.

Other Post :



Related Post of Javascript: