建议首先按照https://discuz.dismall.com/thread-1138816-1-1.html来操作
如果不行行,请按照一下步骤来
假定新定义的文件为script_citys.js
请将里边的函数名都加上1以区别原文件的函数,修改的用CRTL+F修改别遗漏了
比如
/*
[UCenter Home] (C) 2007-2008 Comsenz Inc.
$Id: script_city.js 11751 2009-03-23 10:20:50Z zhengqingpeng $
*/
function setcity1(provinceid, cityid) {
var province = document.getElementById(provinceid).value;
switch (province) {
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 initprovcity1(provinceid, province) {
var provObject = document.getElementById(provinceid);
for(var i = 0; i < provObject.options.length; i++) {
if (provObject.options.value == province) {
provObject.selectedIndex = i;
break;
}
}
//setcity(provinceid, cityid);
}
function showprovince1(provinceid, cityid, province, boxid) {
var provinces = new Array(
"莒县"
);
var selObj = document.createElement("select");
selObj.name = provinceid;
selObj.id = provinceid;
selObj.onchange = function() {
setcity1(provinceid, cityid);
};
$(boxid).appendChild(selObj);
selObj.options[0] = new Option("选择省份", "");
var j = 0;
for(var i = 0; i < provinces.length; i++) {
j = i + 1;
selObj.options[j] = new Option(provinces, provinces);
}
initprovcity1(provinceid, province);
}
function showcity1(cityid, city, provinceid, boxid) {
if(isUndefined(provinceid)) provinceid = '';
var selObj = document.createElement("select");
selObj.name = cityid;
selObj.id = cityid;
$(boxid).appendChild(selObj);
if(city == "") {
selObj.options[0] = new Option("选择城市", "");
} else {
selObj.options[0] = new Option(city, city);
}
if(provinceid != '') {
setcity1(provinceid, cityid);
initprovcity1(cityid, city);
}
}
2这样在调用该文件函数的时候,需要相应的修改比如cp_profile.htm
<th>家乡:</th>
<td id="birthcitybox">
<script type="text/javascript" src="source/script_citys.js"></script>
<script type="text/javascript">
<!--
showprovince1('birthprovince', 'birthcity', '$space[birthprovince]', 'birthcitybox');
showcity1('birthcity', '$space[birthcity]', 'birthprovince', 'birthcitybox');
//-->
</script>
<a href="cp.php?ac=friend&op=search&view=birth" target="_blank">» 查找老乡</a>
</td>
其他仿照来就可以
可查看本人修改的效果,本人网站www.52wenxin.com
文心社区,莒县最大的网上虚拟社区
|