<?php
if (!defined('GV32_COM')) exit('GV32.COM No direct script access allowed');
/**
 *----------------------------------------------------------------------------
 * 版权所有 2005-2010 GV32.COM，并保留所有权利。
 * 网站地址: http://www.gv32.com；
 * 作者: GV32.COM
**/
class Ajaxarea
{
	function Ajaxarea()
	{
	}
	
	function infolist()
	{
	
	}
	
	function province( $paval )
	{
		$sqlarea = " SELECT are_id,are_name  FROM  areadict   WHERE are_parentid = 1  GROUP BY are_id  ";
				
		$areaDetail = $GLOBALS['MySql'] -> selectInfo($sqlarea);
		
		$echoval  =  '<select name="idprovince" id="idprovince" onchange="getareadict( this.value,  \'userd_city\' , \'city\' )" >';
		
		$echoval .= '<option value="" >请选择</option>';
		
		foreach($areaDetail as $akey => $aval)
		{
			if($paval[1]==$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($paval[2]==1)
		{
			echo $selval."&nbsp;";
		}else{
			echo $echoval;
		}
	}
	
	function city( $caval )
	{
		if( $caval[0]!='' )
		{
			$sqlarea = " SELECT are_id,are_name  FROM  areadict   WHERE are_parentid =  ".$caval[0]."  GROUP BY are_id  ";
				
			$areaDetail = $GLOBALS['MySql'] -> selectInfo($sqlarea);
		}
		$echoval  = '<select name="idcity" id="idcity" onchange="getareadict( this.value,  \'userd_district\' , \'district\')" >';
		
		$echoval .= '<option value="" >请选择</option>';
		if($areaDetail!=''){
			foreach($areaDetail as $akey => $aval)
			{
				if($caval[1]==$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($caval[2]==1)
		{
			echo $selval."&nbsp;";
		}else{
			echo $echoval;
		}
	}
	
	function district( $daval )
	{
		//onchange="getareadict( this,  \'userd_city\' , \'district\')"
		if( $daval[0]!='' )
		{
			$sqlarea = " SELECT are_id,are_name  FROM  areadict   WHERE are_parentid = ".$daval[0]."  GROUP BY are_id  ";
					
			$areaDetail = $GLOBALS['MySql'] -> selectInfo($sqlarea);
		}
		$echoval  = '<select name="iddistrict" id="iddistrict"  >';
		
		$echoval .= '<option value="" >请选择</option>';
		if($areaDetail!='')
		{
			foreach($areaDetail as $akey => $aval)
			{
				if($daval[1]==$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($daval[2]==1)
		{
			echo $selval."&nbsp;";
		}else{
			echo $echoval;
		}
	}
}



$Ajaxarea = new Ajaxarea();
?>

