home *** CD-ROM | disk | FTP | other *** search
/ Chip 1998 February / CHIP_2_98.iso / software / pelne / optionp / iis4_07.cab / Arrays_JScript.asp < prev    next >
Text File  |  1997-10-25  |  2KB  |  104 lines

  1. <%@ LANGUAGE = JScript %>
  2. <%
  3.     // Declare a simple fixed size array
  4.     aFixed = new Array(4);
  5.  
  6.     // Declare a dynamic (resizable) array
  7.     aColors = new Array();
  8.  
  9.  
  10.     // Assign values to fixed size array
  11.  
  12.     aFixed[0] = "Fixed";
  13.     aFixed[1] = "Size";
  14.     aFixed[2] = "Array";
  15.     aFixed[3] = "Session ID: " + Session.SessionID;
  16.  
  17.  
  18.     // Store values representing a simple color table
  19.     // to each of the elements
  20.  
  21.     aColors[0] = "RED"; 
  22.     aColors[1] = "GREEN"; 
  23.     aColors[2] = "BLUE";  
  24.     aColors[3] = "AQUA";
  25.     aColors[4] = "YELLOW";
  26.     aColors[5] = "FUCHSIA";
  27.     aColors[6] = "GRAY";
  28.     aColors[7] = "LIME";
  29.     aColors[8] = "MAROON";
  30.     aColors[9] = "NAVY";
  31.     aColors[10] = "OLIVE";
  32.     aColors[11] = "PURPLE";
  33.     aColors[12] = "SILVER";
  34.     aColors[13] = "TEAL";
  35. %>
  36.  
  37. <HTML>
  38.     <HEAD>
  39.         <TITLE>Array Sample</TITLE>
  40.     </HEAD>
  41.  
  42.     <BODY BGCOLOR="White" topmargin="10" leftmargin="10">
  43.  
  44.         <!-- Display Header -->
  45.  
  46.         <FONT SIZE="4" FACE="Arial, Helvetica">
  47.         <B>Array Sample</B></FONT><BR>
  48.       
  49.         <HR SIZE="1" COLOR="#000000">
  50.  
  51.         <TABLE CELLPADDING=10 BORDER=1 CELLSPACING=0>
  52.             <TR>
  53.                 <TD BGCOLOR=WHITE>
  54.                     <FONT SIZE="3" FACE="Arial, Helvetica">
  55.                         <B>A Resizable Array</B><br>
  56.                     </FONT>
  57.                 </TD>
  58.  
  59.                 <TD BGCOLOR=WHITE>
  60.                     <FONT SIZE="3" FACE="Arial, Helvetica">
  61.                         <B>A Fixed Size (4 element) Array</B><BR>
  62.                     </FONT>
  63.                 </TD>
  64.             </TR>
  65.  
  66.             <TR>                
  67.                 <TD>
  68.                     <%
  69.                         // Calculate Array Size
  70.  
  71.                         nColors = aColors.length;
  72.                          
  73.  
  74.                         // Print out contents of resizable array
  75.                         // into table column
  76.  
  77.                         for(i = 0; i < nColors; i++)
  78.                         {
  79.                             Response.Write("<FONT COLOR=" + aColors[i] + ">" + aColors[i] + "<br></FONT>");
  80.                         } 
  81.                     %>
  82.                 </TD>
  83.  
  84.                 <TD>
  85.                     <%
  86.                         // Calculate Array Size                        
  87.                         
  88.                         nColors = aFixed.length;
  89.  
  90.  
  91.                         // Print out contents of fixed array into
  92.                         // table column
  93.  
  94.                         for(i = 0; i < nColors; i++)
  95.                         {
  96.                             Response.Write(aFixed[i] + "<br>");
  97.                         } 
  98.                     %>
  99.                 </TD>
  100.             </TR>
  101.         </TABLE>
  102.     </BODY>
  103. </HTML>
  104.