Previous Example-|-Next Example-|-Return to Chapter Listing

Example 9.3:
Select One Array, See Another

Select the array and position and then click on the button to see what is held in that position:
Select the area for which you want to retrieve the area code:

This is the script we used in the HEAD: <SCRIPT LANGUAGE="JAVASCRIPT"> <!-- // generic object maker prepares an empty array of n items function makeArray(n) { this.length = n for (var i=1; i <= n; i++){ this[i] = null; } return this } // create object listing all the top end of each numeric range var cde = new makeArray(187) var area = new makeArray(187) area[1] = "Alabama "; cde[1] = 205 area[2] = "Alabama "; cde[2] = 334 area[3] = "Alaska "; cde[3] = 907 area[4] = "Alberta "; cde[4] = 403 area[5] = "Antigua "; cde[5] = 268 area[6] = "Arizona "; cde[6] = 520 area[7] = "Arizona "; cde[7] = 602 area[8] = "Arkansas "; cde[8] = 501 area[9] = "Bahamas "; cde[9] = 242 area[10] = "Barbados "; cde[10] = 246 area[11] = "Bermuda "; cde[11] = 441 area[12] = "British Columbia "; cde[12] = 250 area[13] = "British Columbia "; cde[13] = 604 //--> </SCRIPT> And this form: <FORM> Select the area for which you want to retrieve the area code: <select name="area" size="14"> <option > <option selected option>Alabama 1 <option> Alabama 2 <option> Alaska <option> Alberta <option> Antigua <option> Arizona 1 <option> Arizona 2 <option> Arkansas <option> Bahamas <option> Barbados <option> Bermuda <option> British Columbia 1 <option> British Columbia 2 </select><BR> <INPUT TYPE="button" VALUE="What's the area code?" onclick="form.returninfo.value=cde[form.area.selectedIndex]"> <INPUT TYPE="TEXT" NAME="returninfo"> </FORM>
Previous Example-|-Next Example-|-Return to Chapter Listing