Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我需要做一个快速而肮脏的Country-->State在 Web 表单上下拉关系。我只关心美国和加拿大的州、省和地区,这将是一种相对较少使用的形式,因此纯 JavaScript 解决方案可能是理想的。
Country
State
创建一个 JSON 数组:
array = [ { name: "United States", states: [...] }, { ... } ];
当下拉列表的值发生变化时,用数组中特定元素的内容填充另一个下拉列表。