A Simple Parallel Array Lookup : Array : Language Basics JAVASCRIPT DHTML TUTORIALS


JAVASCRIPT DHTML TUTORIALS » Language Basics » Array »

 

A Simple Parallel Array Lookup



/*
JavaScript Bible, Fourth Edition
by Danny Goodman 

John Wiley & Sons CopyRight 2001
*/


<HTML>
<HEAD>
<TITLE>Parallel Array Lookup</TITLE>
<SCRIPT LANGUAGE="JavaScript">
// the data
var regionalOffices = new Array("New York""Chicago""Houston""Portland"
var regionalManagers = new Array("Shirley Smith""Todd Gaston""Leslie Jones""Harold Zoot"
var regOfficeQuotas = new Array(300000250000350000225000
// do the lookup into parallel arrays
function 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>

           
       



-

Leave a Comment / Note


 
Verification is used to prevent unwanted posts (spam). .

Follow Navioo On Twitter

JAVASCRIPT DHTML TUTORIALS

 Navioo Language Basics
» Array