Get the App
SLTechnology News&Howtos  ›  Internet Technology  › 

How to use JavaScript to realize a two-level linkage drop-down box

Shulou Source: shulou.com Published: 2022-05-31 10:52:28 10月01日 Update

This article mainly explains "how to use JavaScript to achieve a two-level linkage drop-down box", the content of the article is simple and clear, easy to learn and understand, the following please follow the editor's ideas slowly in depth, together to study and learn "how to use JavaScript to achieve a two-level linkage drop-down box" bar!

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

Tags: Drop-down object city code array province index property content method learning customer is location language problem order processing selection label value Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Apple Shulou Tech Info Shulou Technology Xiaomi MariaDB