When the Database Query page is designed, the drop-down menu is an element that is often used. Many times you would like to choose one of the drop-down menu, the content of the other drop-down menu will change. This feature can be implemented by refreshing the page, but the interface is not so friendly. In this paper, you can achieve the purpose of refreshing the page. When a province is selected in the drop-down menu, another drop-down menu will appear some cities for the province. My basic idea is: In the client script, all the contents of the drop-down menu may appear firstly store in an array, and then extract data from the array as needed to write the drop-down menu. The following is a complete code:
HEAD>
// Define a two-dimensional array AARRAY to store the city name.
VAR ACITY = New Array ();
ACITY [0] = new array ();
ACITY [1] = New Array ();
ACITY [2] = New Array ();
ACITY [3] = New Array ();
// Assignment, the city in each province stores a line of array.
ACITY [0] [0] = "- Please select -"
ACITY [1] [0] = "- Please select -"
ACITY [1] [1] = "Guangzhou";
ACITY [1] [2] = "Shenzhen";
ACITY [1] [3] = "Zhuhai City";
ACITY [1] [4] = "Shantou";
ACITY [1] [5] = "Foshan";
ACITY [2] [0] = "- Please select -"
ACITY [2] [1] = "Changsha";
ACITY [2] [2] = "Zhuzhou";
ACITY [2] [3] = "Xiangtan City";
ACITY [3] [0] = "- Please select -"
ACITY [3] [1] = "Hangzhou";
ACITY [3] [2] = "Suzhou";
ACITY [3] [3] = "Wenzhou";
Function changecity ()
{VAR I, iProvinceIndex;
iProvinceIndex = document.frm.optprovince.selectedIndIndex
ICITYCOUNT = 0;
While (Acity "! = null) iCityCount ; // Calculate the number of urban numbers selected
Document.frm.optcity.Length = iCityCount; // change the number of options for the drop-down menu
For (i = 0; i <= iciTyCount-1; i ) // change the content of the drop-down menu
Document.frm.optcity [i] = new option (ACITY [iProvinceIndex] [i]);
Document.frm.optcity.focus ()
}
->
Script>