Get the App
SLTechnology News&Howtos  ›  Internet Technology  › 

How to realize a two-stage linkage drop-down box by JavaScript

Shulou Source: shulou.com Published: 2022-05-31 11:46:29 10月01日 Update

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

Tags: Object drop-down city code array province index property content method customer location more knowledge language order processing selection achievement standard value Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno NVidia Linux Shulou Information macOS Shulou Technology