Javascript Array

This is simple Javascript showing how to create an array. It extends our first array example by adding additional arrays to the function.

Javascript in Action



Javascript Code

Javascript and html code are self contained below.

 
     
<html>
<script language="javascript"> 
<!-- //hide code from older browsers	
  function listBucket(v) {
   var rLst;
   var lst1 = ["1a","1b","1c","1d"];
   var lst2 = ["2a","2b","2c"];
   var lst3 = ["3a","3b","3c","4d"];
   if (v === "list1") {
     rLst = lst1;
   } 
   else if (v === "list2") {
     rLst = lst2;
   } 
   else if (v === "list3") {
     rLst = lst3;
   } 
   //end if

//code contained here is only here so you can see the output in the browser! 
  alert( rLst );
///////////////////////////////////////////////////////////////////////////
   return rLst;
  } //end function   
// end hiding -->
</script>
</head>
<body>
<form>
<input type="button" value="Run" onclick="listBucket('list2')" />
</form>
</body>
</html>	
 

If you find this site useful and are a book buyer/reader...

Abe Books is one of my affiliates. I only use affiliates that I also purchase products from. I love Abe books. I have purchased many books from them originally cost $40 to $60 for as little as $5 to $10 dollars including shipping costs.

By accessing Abe books and clicking on one of my links I receive a small commission on your purchase that helps pay for this site. You pay no more for your books than if you accessed their site directly. Thanks for your support.

I have found Javascript - The Good Parts to be an indespensible resource

Click on the book to find books on Javascript at Abe Books...

If you would like a new version of the book click below to buy it from Amazon (also one of my affiliates).

Javascript Examples

Basics

Forms

Misc













navTango.com free

75% of your donation

goes to charity.