/*JavaScript Bible, Fourth Editionby Danny Goodman John Wiley & Sons CopyRight 2001*/<HTML><HEAD><TITLE>Parallel Array Lookup</TITLE><SCRIPT LANGUAGE="JavaScript">// the datavar regionalOffices = new Array("New York", "Chicago", "Houston", "Portland") var regionalManagers = new Array("Shirley Smith", "Todd Gaston", "Leslie Jones", "Harold Zoot") var regOfficeQuotas = new Array(300000, 250000, 350000, 225000) // do the lookup into parallel arraysfunction getData(form) { var i = form.offices.selectedIndex form.manager.value = regionalManagers[i] form.quota.value = regOfficeQuotas[i] } </SCRIPT></HEAD><BODY onLoad="getData(document.officeData)"><H1>Parallel Array Lookup</H1><HR><FORM NAME="officeData"> <P> Select a regional office: <SELECT NAME="offices" onChange="getData(this.form)"> <OPTION>New York <OPTION>Chicago <OPTION>Houston <OPTION>Portland </SELECT> </P><P> The manager is: <INPUT TYPE="text" NAME="manager" SIZE=35> <BR> The office quota is: <INPUT TYPE="text" NAME="quota" SIZE=8> </P> </FORM> </BODY></HTML>
Name (required)
email (will not be published) (required)
Website