本帖最后由 baolei 于 2010-01-08 14:19 编辑
预览地址:www.jldh.net/home
预览图片:
安装说明:\home\source\
只需一步:根据个人需要修改 script_city.js
- /*
- [UCenter Home] (C) 2007-2008 Comsenz Inc.
- $Id: script_city.js 8422 2009-03-15 09:10:00Z baolei $
- */
- function setcity(provinceid, cityid) {
- var province = document.getElementById(provinceid).value;
- switch (province) {
- case "敦化市区" :
- var cityOptions = new Array(
- "敦化市(*)", "敦化市",
- "渤海街", "渤海街",
- "胜利街", "胜利街",
- "民主街", "民主街",
- "丹江街", "丹江街",
- "大石头", "大石头",
- "黄泥河", "黄泥河",
- "官地镇", "官地镇",
- "沙河沿", "沙河沿",
- "秋梨沟", "秋梨沟",
- "额穆镇", "额穆镇",
- "贤儒镇", "贤儒镇",
- "大蒲柴", "大蒲柴",
- "雁鸣湖", "雁鸣湖",
- "江源镇", "江源镇",
- "江南镇", "江南镇",
- "大桥乡", "大桥乡",
- "黑石乡", "黑石乡",
- "翰章乡", "翰章乡",
- "红石乡", "红石乡");
- break;
- case "非敦化市" :
- var cityOptions = new Array(
- "北京", "东城",
- "上海", "西城",
- "重庆", "崇文",
- "安徽", "安徽",
- "福建", "福建",
- "甘肃", "甘肃",
- "广东", "广东",
- "广西", "广西",
- "贵州", "贵州",
- "海南", "海南",
- "河北", "河北",
- "黑龙江", "黑龙江",
- "河南", "河南",
- "香港", "香港",
- "湖北", "湖北",
- "湖南", "湖南",
- "江苏", "江苏",
- "江西", "江西",
- "吉林", "吉林",
- "辽宁", "辽宁",
- "澳门", "澳门",
- "内蒙古", "内蒙古",
- "青海", "青海",
- "山东", "山东",
- "山西", "山西",
- "陕西", "陕西",
- "四川", "四川",
- "台湾", "台湾",
- "天津", "天津",
- "新疆", "新疆",
- "西藏", "西藏",
- "云南", "云南",
- "浙江", "浙江",
- "海外", "海外");
- break;
- default:
- var cityOptions = new Array("选择城镇", "");
- break;
- }
-
- var cityObject = document.getElementById(cityid);
- cityObject.options.length = 0;
- cityObject.options[0] = new Option("选择城镇", "");
- var j = 0;
- for(var i = 0; i < cityOptions.length/2; i++) {
- j = i + 1;
- cityObject.options[j] = new Option(cityOptions[i*2],cityOptions[i*2+1]);
- }
- }
- function initprovcity(provinceid, province) {
- var provObject = document.getElementById(provinceid);
- for(var i = 0; i < provObject.options.length; i++) {
- if (provObject.options[i].value == province) {
- provObject.selectedIndex = i;
- break;
- }
- }
- //setcity(provinceid, cityid);
- }
- function showprovince(provinceid, cityid, province) {
- var provinces = new Array(
- "敦化市区", "非敦化市"
- );
- var html = "<select name="" + provinceid + "" id="" + provinceid + "" onchange="setcity('" + provinceid + "', '" + cityid + "');">";
- html = html + "<option value="">选择地区</option>";
- for(var i = 0; i < provinces.length; i++) {
- html = html + "<option value="" + provinces[i] + "">" + provinces[i] + "</option>";
- }
- html = html + "</select>";
- document.write(html);
- initprovcity(provinceid, province);
- }
- function showcity(cityid, city, provinceid) {
- if(isUndefined(provinceid)) provinceid = '';
- var html = " <select name="" + cityid + "" id="" + cityid + "">";
- if(provinceid == '') {
- if(city == "") {
- html = html + "<option value="">选择城镇</option>";
- } else {
- html = html + "<option value="" + city + "">" + city + "</option>";
- }
- }
- html = html + "</select>";
- document.write(html);
- if(provinceid != '') {
- setcity(provinceid, cityid);
- initprovcity(cityid, city);
- }
- }
复制代码 简简单单,所有版本通用.希望对大家有所帮助.
免费:
支持: |