• 每天一个JavaScript实例-动态省份选择城市


    <!DOCTYPE html>
    <html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
    <title>每天一个JavaScript实例-动态省份选择城市</title>
    <script>
    var citystore = new Array();
    citystore = [['SD','济南'],['SD','烟台'],['SD','青岛'],['SX','太原'],['BJ','北京'],['HN','海南']];
    window.onload = function(){
    	document.getElementById("state").onchange=changecity;
    }
    function changecity(){
    	var state = this.value;
    	var city = document.getElementById('cities');
    	city.options.length = 0;
    	for(var i = 0; i <citystore.length;i++){
    		if(state == citystore[i][0]){
    			var opt =new Option(citystore[i][1]);
    			try{
    				city.add(opt,null);
    			}catch(e){
    				city.add(opt);
    			}
    		}
    
    	}
    
    }
    </script>
    
    </head>
    
    <body>
    
    <form id="picker" method="post" action="">
    	<select id = "state">
    		<option value="">--</option>
    		<option value="SD">山东</option>
    		<option value="SX">山西</option>
    		<option value="BJ">北京</option>
    		<option value="HN">海南</option>
    	</select>
    	<select id="cities">
    		
    	</select>
    
    </form>
    
    </body>
    </html>
    

  • 相关阅读:
    ActiveReports打印的问题
    HTML高级应用
    一些常用的asp.net技巧焦点篇
    数据库操作
    [ASP.NET]在后台引用JavaScript
    点击TextBox复制其中内容
    VB.Net基本语句(推荐)
    ADO 对象
    控件不获得焦点
    32款网站优化工具
  • 原文地址:https://www.cnblogs.com/blfshiye/p/5059188.html
Copyright © 2020-2023  润新知