首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 网站开发 > Web前端 >

省级联简单示例

2012-08-13 
省份级联简单示例!DOCTYPE HTML PUBLIC -//W3C//DTD HTML 4.01 Transitional//ENhttp://www.w3.org/TR

省份级联简单示例

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN""http://www.w3.org/TR/html4/loose.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8" /><title>New Web Project</title><script type="text/javascript">var sf = new Array();sf[0] = new Array("0","--请选择省份--");var gd = new Array();gd[0] = new Array("0","广东");gd[1] = new Array("1","深圳");var zj = new Array();zj[0]  = new Array("0","杭州");zj[1] = new Array("1","宁波")function showCity(pe){for (var i=0; i<pe.length;i++){document.f.city.options[i] = new Option(pe[i][1],pe[i][0]);}}function choose(){var tag = document.f.p.value;switch(tag){case '0':init();showCity(sf);break;case '1':init();showCity(gd);break;case '2':init();showCity(zj);break;}}function init(){var len = document.f.city.options.length;for (var i = 0; i<len; i++){document.f.city.remove(i);}}function flush(){document.f.p.options[0].selected = true;}</script></head><body onload="flush()"><h1>省市级联</h1><form name="f"><select name="p" onchange="choose()"><option value="0" selected>--省份</option><option value="1">广东</option><option value="2">浙江</option></select><select name="city"><option value="0">城市</option></select></form></body></html>

热点排行