自动获取“省-市-县-乡镇”地址 For UCH 2.0

以下方法根据discuz!x修改,可用于UCH

common_district.sql //来源DX
function_profile.php //来源DX

1、打开cp_profile.htm文件,

修改


2、打开script_common.js文件,添加:

function showdistrict(container, elems, totallevel, changelevel) {
	var getdid = function(elem) {
		var op = elem.options[elem.selectedIndex];
		return op['did'] || op.getAttribute('did') || '0';
	};
	var pid = changelevel >= 1 && elems[0] && $(elems[0]) ? getdid($(elems[0])) : 0;
	var cid = changelevel >= 2 && elems[1] && $(elems[1]) ? getdid($(elems[1])) : 0;
	var did = changelevel >= 3 && elems[2] && $(elems[2]) ? getdid($(elems[2])) : 0;
	var coid = changelevel >= 4 && elems[3] && $(elems[3]) ? getdid($(elems[3])) : 0;
	var url = "cp.php?ac=common&op=district&container="+container
		+"&province="+elems[0]+"&city="+elems[1]+"&district="+elems[2]+"&community="+elems[3]
		+"&pid="+pid + "&cid="+cid+"&did="+did+"&coid="+coid+'&level='+totallevel+'&handlekey='+container+'&inajax=1';
	ajaxget(url, container, '');
}

3、打开cp_common.php文件,最后}替换为

} elseif($op == 'district') {
	$showlevel = intval($_GET['level']);
	$showlevel = $showlevel >= 1 && $showlevel <= 4 ? $showlevel : 4;
	$values = array(intval($_GET['pid']), intval($_GET['cid']), intval($_GET['did']), intval($_GET['coid']));
	$elems = array();
	if($_GET['province']) {
		$elems = array($_GET['province'], $_GET['city'], $_GET['district'], $_GET['community']);
	}
	$container = $_GET['container'];
	include_once (S_ROOT.'./source/function_profile'.php);
	$html = showdistrict($values, $elems, $container, $showlevel);
}

4、打开cp_common.htm文件,最后


替换为:


$html

未完待续。

转载请注明出处:https://www.onexin.net/automatically-selects-the-province-city-county-township-address/

随机文章:

1、什么是 WebSocket
https://www.onexin.net/websocket/

2、建站技术-apache+mysql+php+ssl服务器之完全安装攻略
https://www.onexin.net/the-establishment-of-the-station-technology-the-apache-mysql-php-ssl-server-the-installation-completely-raiders/

3、正确的网站定位是网站成功的基础
https://www.onexin.net/web-site-correctly-positioning-is-the-basis-for-success/

4、PHP 后端实现JWT认证方法示例
https://www.onexin.net/php-jwt/

5、Codeigniter的一些优秀实践 使用规范总结
https://www.onexin.net/codeigniter-practice/

Leave a Reply