Простой поиск в параллельном массиве
<html>
<head>
<title>Parallel Array Lookup</title>
<script language ="JavaScript">
// данные
var regionalOffices = new Array("New York", "Chicago", "Houston", "Portland")
var regionalManagers = new Array("Shirley Smith", "Todd Gaston", "Leslie Jones", "Harold Soot")
var regOfficeQuotas = new Array(300000, 25000C, 350000, 225000)
// функция поиска в параллельных массивах
function getData(form){
var i = form.offices.selectedlndex
form.manager.value = regionalKanagers[i]
form.quota.value = regOfficeQuotas [i]
}
</script>
</head>
<body onLoad="getData (document.officeData)">
<h1>Parallel Array Lookup</h1>
<form name ="officeData">
Select a regional office:
<select name ="offices" onChange="getData(this.form)">
<option>New York
<option>Chicago
<option>Houston
<option>Portland
</select>
The manager is:
<input type ="text" name="manager" size=35>
<br>
The office quota is:
<input type="text" name="quota">
</form>
</body>
</html>