Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <!DOCTYPE html>
- <html>
- <head>
- <meta charset="utf-8">
- <title></title>
- </head>
- <body>
- <form id="picker" action="" method="post">
- <select id="state">
- <option value="">--</option>
- <option value="MO">Missouri</option>
- <option value="WA">Washington</option>
- <option value="CA">California</option>
- </select>
- <select id="cities">
- </select>
- </form>
- <script>
- var citystore = new Array();
- citystore[0] = ["CA", "San Francisco"];
- citystore[1] = ["CA", "Los Angeles"];
- citystore[2] = ["CA", "San Diego"];
- citystore[3] = ["MO", "St. Louis"];
- citystore[4] = ["MO", "Kansas City"];
- citystore[5] = ["WA", "Seattle"];
- citystore[6] = ["WA", "Spokane"];
- citystore[7] = ["WA", "Redmond"];
- window.onload = function() {
- document.getElementById("state").onchange = filterCities;
- };
- function filterCities() {
- var state = this.value;
- var city = document.getElementById("cities");
- city.options.length = 0;
- for (var i = 0; i < citystore.length; i++) {
- var st = citystore[i][0];
- if (st == state) {
- var opt = new Option(citystore[i][1]);
- try {
- city.add(opt, null);
- } catch (e) {
- city.add(opt);
- }
- }
- }
- }
- </script>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement