<?php
/**
 *----------------------------------------------------------------------------*
 * 版权所有 2010-2016 HuCart.COM，并保留所有权利。
 * 网站地址: http://Www.HuCart.Com；
 * 作者: HuCart.COM
 *----------------------------------------------------------------------------*
**/
class Ajaxarea
{
	function Ajaxarea()
	{
	}
	
	function infolist()
	{
		
	}
	
	function province()
	{
		$objval = $GLOBALS['Reque'] -> reqval["objval"];
		$selval	= $GLOBALS['Reque'] -> reqval["selval"];
		$sqlarea = " SELECT are_id,are_name  FROM  ".SQL_PREFIX."areadict   WHERE are_parentid = 1  GROUP BY are_id  ";
				
		$areaDetail = $GLOBALS['MySql'] -> select_info($sqlarea);
		
		$echoval  =  '<select name="idprovince" id="idprovince" onchange="getareadict( this.value,  \'userd_city\' , \'city\' );provinceval(this);" >';
		
		$echoval .= '<option value="" >请选择</option>';
		
		foreach($areaDetail as $akey => $aval)
		{
			if($selval==$aval["are_id"])
			{
				$echoval .= '<option value='.$aval["are_id"].' selected=\'selected\' >'.$aval["are_name"].'</option>';
				$selval = $aval["are_name"];
			}else{
				$echoval .= '<option value='.$aval["are_id"].' >'.$aval["are_name"].'</option>';
			}
		}
		
		$echoval .= '</select>';
		if($selval==1)
		{
			echo $selval."&nbsp;";
		}else{
			echo $echoval;
		}

	}
	
	function city()
	{
		
		$objval = $GLOBALS['Reque'] -> reqval["objval"];
		$selval	= $GLOBALS['Reque'] -> reqval["selval"];
		
		if( $objval!='' )
		{
			$sqlarea = " SELECT are_id,are_name  FROM  ".SQL_PREFIX."areadict   WHERE are_parentid =  ".$objval."  GROUP BY are_id  ";
				
			$areaDetail = $GLOBALS['MySql'] -> select_info($sqlarea);
		}
		$echoval  = '<select name="idcity" id="idcity" onchange="getareadict( this.value,  \'userd_district\' , \'district\');cityval(this);" >';
		
		$echoval .= '<option value="" >请选择</option>';
		if($areaDetail!=''){
			foreach($areaDetail as $akey => $aval)
			{
				if($selval==$aval["are_id"])
				{
					$echoval .= '<option value='.$aval["are_id"].' selected=\'selected\' >'.$aval["are_name"].'</option>';
					$selval = $aval["are_name"];
				}else{
					$echoval .= '<option value='.$aval["are_id"].' >'.$aval["are_name"].'</option>';
				}
			}
		}
		$echoval .= '</select>';
		if($selval==1)
		{
			echo $selval."&nbsp;";
		}else{
			echo $echoval;
		}
		exit();
	}
	
	function district()
	{
		$objval = $GLOBALS['Reque'] -> reqval["objval"];
		$selval = $GLOBALS['Reque'] -> reqval["selval"];
		
		if( $objval!='' )
		{
			$sqlarea = " SELECT are_id,are_name  FROM  ".SQL_PREFIX."areadict   WHERE are_parentid = ".$objval."  GROUP BY are_id  ";
					
			$areaDetail = $GLOBALS['MySql'] -> select_info($sqlarea);
		}
		$echoval  = '<select name="iddistrict" id="iddistrict" onchange="districtval(this)" >';
		
		$echoval .= '<option value="" >请选择</option>';
		if($areaDetail!='')
		{
			foreach($areaDetail as $akey => $aval)
			{
				if($selval==$aval["are_id"])
				{
					$echoval .= '<option value='.$aval["are_id"].' selected=\'selected\' >'.$aval["are_name"].'</option>';
					$selval = $aval["are_name"];
				}else{
					$echoval .= '<option value='.$aval["are_id"].' >'.$aval["are_name"].'</option>';
				}
			}
		}
		$echoval .= '</select>';
		if($selval==1)
		{
			echo $selval."&nbsp;";
		}else{
			echo $echoval;
		}
	}
}

$Ajaxarea = new Ajaxarea();
//echo $GLOBALS['Webur'] -> getval["type"];
if($GLOBALS['Webur'] -> getval["type"]=='province')
{
	
	$Ajaxarea -> province();
}else if($GLOBALS['Webur'] -> getval["type"]=='city')
{
	$Ajaxarea -> city();
}if($GLOBALS['Webur'] -> getval["type"]=='district')
{
	$Ajaxarea -> district();
}else{
	exit();
}
?>

