php省市区三级联动 我是个菜鸟,问下有没有php省市区三级联动直接能用的源代码,让我学习学习!谢谢 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 http://download.csdn.net/download/fujun2013/3850032 http://download.csdn.net/download/ajaxoo/9562686 index.php<?php/** * User: xinxinj * Date: 15/8/13 * Time: 下午9:35 */// 分类include "UnlimitedClassIfication.php";$object = new UnlimitedClassIfication();$a = $object->getArea();?><html> <title>三级联动</title> <body> <select class="cate" data-flag="1" id="f1"> <option value="0">请选择</option> <?php foreach ($a as $k => $v) :?> <option value="<?php echo $k; ?>"><?php echo $v; ?></option> <?php endforeach; ?> </select> <select class="cate" data-flag="2" id="f2"> <option value="0">请选择</option> </select> <select class="cate" data-flag="3" id="f3"> <option value="0">请选择</option> </select> </body> <script src="jq.js"></script> <script type="text/javascript"> $(".cate").change(function(){ var type = $(this).val(); var id = $(this).attr("data-flag"); if (id != 3) { if (id == 1) { $("#f"+id).next().next().html(""); } $.ajax({ url:"http://test.com/UnlimitedClassIfication.php", type:"get", data:{"flag":1, "type":type}, async:false, success:function(a) { var a = eval("("+ a + ")"); // alert(a.status); if(a.status == 0) { alert(a.mess); } else if (a.status == 1) { $("#f"+id).next().html(a.data); } } }); } }); </script></html>UnlimitedClassIfication.php<?php/** * User: xinxinj * Date: 15/8/13 * Time: 下午9:35 *//** * 三级联动 */class UnlimitedClassIfication{ /** * 地区信息. * * @return array. */ function area () { return array( 1 => array( 2 => "北京", 3 => "山西" ), 2 => array( 4 =>"北京", ), 3 => array( 5 => "太原", 6 => "晋中" ), 4 => array( 7 => "朝阳", 8 => "海淀" ), 5 => array( 9 => "清徐", 10 => "小店", ), 6 => array( 11 => "介休", 12 => "太谷" ) ); } /** * 获取一级分类. * * @return return */ function getArea () { $area = $this->area(); return $area[1]; } /** * 三级联动. * * @param int $type 分类标识. * * @return string */ function getUnlimitedClassIfication ($type) { header("Content-type: text/html; charset=utf-8"); $area = $this->area(); if (isset($area[$type])) { $content = "<option value=0>请选择</option>"; foreach ($area[$type] as $k => $v) { $content .= "<option value='{$k}'>{$v}</option>"; } $return = array("status" => 1, "mess" => "", "data" => $content);; } else { $return = array("status" => 0, "mess" => "该分类不存在子分类", "data" => array()); } echo json_encode($return); }}if (isset($_GET['flag'])) { $type = $_GET['type']; $object = new UnlimitedClassIfication(); $object->getUnlimitedClassIfication($type);} 诚邀PHP技术人员加盟 php ci框架 读取excel 到数据库。着急。。。 内容管理系统 LyftenBloggie 有谁用过啊,高手进来一下啊 preg_match 正则如何判断这批符号? 关于这个php远程下载的代码!!!!!!!!!!!!! 做电子商务网站,有用过的zen-cart opencart oscommerce ecshop的,哪一个好! 一个简单的正则匹配问题 PHP上传控件求助 discuz的频道录入数据的界面如何扩展 请问建立这种网站,用哪个开源网站模板。 php memcache
/**
* User: xinxinj
* Date: 15/8/13
* Time: 下午9:35
*/// 分类
include "UnlimitedClassIfication.php";
$object = new UnlimitedClassIfication();
$a = $object->getArea();
?>
<html>
<title>三级联动</title>
<body>
<select class="cate" data-flag="1" id="f1">
<option value="0">请选择</option>
<?php foreach ($a as $k => $v) :?>
<option value="<?php echo $k; ?>"><?php echo $v; ?></option>
<?php endforeach; ?>
</select>
<select class="cate" data-flag="2" id="f2">
<option value="0">请选择</option>
</select>
<select class="cate" data-flag="3" id="f3">
<option value="0">请选择</option>
</select>
</body>
<script src="jq.js"></script>
<script type="text/javascript">
$(".cate").change(function(){
var type = $(this).val();
var id = $(this).attr("data-flag");
if (id != 3) {
if (id == 1) {
$("#f"+id).next().next().html("");
}
$.ajax({
url:"http://test.com/UnlimitedClassIfication.php",
type:"get",
data:{"flag":1, "type":type},
async:false,
success:function(a) {
var a = eval("("+ a + ")");
// alert(a.status);
if(a.status == 0) {
alert(a.mess);
} else if (a.status == 1) {
$("#f"+id).next().html(a.data);
}
}
});
}
});
</script>
</html>
UnlimitedClassIfication.php
<?php
/**
* User: xinxinj
* Date: 15/8/13
* Time: 下午9:35
*//**
* 三级联动
*/
class UnlimitedClassIfication
{
/**
* 地区信息.
*
* @return array.
*/
function area ()
{
return array(
1 => array(
2 => "北京",
3 => "山西"
),
2 => array(
4 =>"北京",
),
3 => array(
5 => "太原",
6 => "晋中"
),
4 => array(
7 => "朝阳",
8 => "海淀"
),
5 => array(
9 => "清徐",
10 => "小店",
),
6 => array(
11 => "介休",
12 => "太谷"
)
);
} /**
* 获取一级分类.
*
* @return return
*/
function getArea ()
{
$area = $this->area(); return $area[1];
} /**
* 三级联动.
*
* @param int $type 分类标识.
*
* @return string
*/
function getUnlimitedClassIfication ($type)
{
header("Content-type: text/html; charset=utf-8"); $area = $this->area();
if (isset($area[$type])) {
$content = "<option value=0>请选择</option>";
foreach ($area[$type] as $k => $v) {
$content .= "<option value='{$k}'>{$v}</option>";
}
$return = array("status" => 1, "mess" => "", "data" => $content);;
} else {
$return = array("status" => 0, "mess" => "该分类不存在子分类", "data" => array());
} echo json_encode($return);
}}if (isset($_GET['flag'])) {
$type = $_GET['type'];
$object = new UnlimitedClassIfication();
$object->getUnlimitedClassIfication($type);
}