本帖最后由 kangkanglei 于 2008-12-14 08:24 编辑
这两天正自己作站,用到UCH,上来看到诸多问这个问题的。
就说一下我改的办法。
演示地址www.zanquan.com
新建script_citys.js,放在script_city.js同目录下
复制以下代码到script_citys.js中- /*
- [UCenter Home] (C) 2007-2008 Comsenz Inc.
- $Id: script_city.js 8422 2008-08-07 09:10:00Z zhengqingpeng $
- */
- function setcity2(provinceid2, cityid2) {
- var province2 = document.getElementById(provinceid2).value;
- switch (province2) {
- case "安徽" :
- var cityOptions = new Array(
- "合肥(*)", "合肥",
- "安庆", "安庆",
- "蚌埠", "蚌埠");
- break;
- case "北京" :
- var cityOptions = new Array(
- "东城", "东城",
- "西城", "西城",
- "崇文", "崇文");
- break;
- default:
- var cityOptions = new Array("选择城市", "");
- break;
- }
-
- var cityObject2 = document.getElementById(cityid2);
- cityObject2.options.length = 0;
- cityObject2.options[0] = new Option("选择城市", "");
- var j = 0;
- for(var i = 0; i < cityOptions.length/2; i++) {
- j = i + 1;
- cityObject2.options[j] = new Option(cityOptions[i*2],cityOptions
- [i*2+1]);
- }
- }
- function initprovcity(provinceid2, province) {
- var provObject = document.getElementById(provinceid2);
- for(var i = 0; i < provObject.options.length; i++) {
- if (provObject.options[i].value == province) {
- provObject.selectedIndex = i;
- break;
- }
- }
- //setcity2(provinceid2, cityid2);
- }
- function showprovince(provinceid2, cityid2, province) {
- var provinces = new Array(
- "北京", "安徽"
- );
- var html = "<select name="" + provinceid2 + "" id="" + provinceid2
- + "" onchange="setcity2('" + provinceid2 + "', '" + cityid2 + "');">";
- 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(provinceid2, province);
- }
- function showcity(cityid2, city, provinceid2) {
- if(isUndefined(provinceid2)) provinceid2 = '';
- var html = " <select name="" + cityid2 + "" id="" + cityid2 +
- "">";
- if(provinceid2 == '') {
- if(city == "") {
- html = html + "<option value="">选择城市</option>";
- } else {
- html = html + "<option value="" + city + "">" + city
- + "</option>";
- }
- }
- html = html + "</select>";
- document.write(html);
- if(provinceid2 != '') {
- setcity2(provinceid2, cityid2);
- initprovcity(cityid2, city);
- }
- }
复制代码 然后找到\admin\tpl\script_city.js; \template\default\下面的cp_friend.htm,cp_profile.htm,network_space.htm,这四个文件
查找“居住地”,找紧接“居住地”后的- <script type="text/javascript">
复制代码 代码,,在次代码之“前”添加- <script type="text/javascript" src="source/script_citys.js"></script>
复制代码 这样,修改script_city.js就可以定义出生,修改script_citys.js就可以定义居住地
还有,此时首页的搜索为“出生地”,把\template\default\下的index.htm中的script_city.js该为script_citys.js 即可换位搜索居住地
network_index.htm文件同理。
语言表达能力有限,希望大家能看明白 |