How to realize a two-stage linkage drop-down box by JavaScript
This article introduces the relevant knowledge of "how to achieve a two-level linkage drop-down box in JavaScript". In the operation of actual cases, many people will encounter such a dilemma, so let the editor lead you to learn how to deal with these situations. I hope you can read it carefully and be able to achieve something!
Javascript is a case-sensitive client scripting language for object-oriented dynamic types, which is developed from Netscape's LiveScript. The main purpose is to solve the speed problem left over by server-side languages, such as Perl, and to provide customers with smoother browsing results.
Display code printing
New Document / / defines a two-dimensional array of cities in the same order as the provinces. Obtain the corresponding city array var city= ["Beijing", "Tianjin", "Shanghai", "Chongqing"], ["Nanjing", "Suzhou", "Nantong", "Changzhou"], ["Fuzhou", "Fu'an", "Longyan", "Nanping"], [Guangzhou "," Chaoyang "," Chaozhou "," Chenghai "], [Lanzhou"]. "Baiyin", "Dingxi", "Dunhuang"] Function getCity () {/ / get the object of the province drop-down box var sltProvince=document.form1.province; / / get the city drop-down box object var sltCity=document.form1.city; / / get the city array var provinceCity=city of the corresponding province [sltProvince.selectedIndex-1]; / / clear the city drop-down box, leaving only the prompt option sltCity.length=1; / / populate the city drop-down box with the values in the city drop-down box for (var icities 0 countries I