<?php
 
session_start();
include("DMMYSQLG.php");
$com = "M";
include("DSA3000.php");
include("JQUERY.inc");
?>
<html>
<link rel="stylesheet" href="css/estilo1.css" type="text/css"/>
<script type="text/javascript" language="JavaScript1.2" src="DSSCRIPT.js"></script>
<?php

if (!isset($_POST['bot'])){
	echo '<h2>!!! Selecciona un Registro !!!</h2>';
	echo '<meta content="1; url=cat_codigos_PR.php"  HTTP-EQUIV="REFRESH">';
}else{
	include('cat_codigos_CL.php');
	$data['idColonia']=$_POST['bot'];
	$varible_clase = new Coloni($data);	
	$res=$varible_clase->busReg();
	$reg=mysqli_fetch_array($res);
?>
<body
<?php
 
if(isset($_POST['bot3'])){
	echo ' onLoad="deshab()"';
}
?>
>
<form  name="frm1" id="frm1" method="post" action="">
<input name="t_num" type="hidden" value="<?php
 echo $_POST["bot"]?>">
  <table width="396"  align="center">
    <tr> 
      <th colspan="2" class=\"titulo\"><div align="center">CONSULTA DE COLONIA </div></th>
    </tr>
    <tr> 
      <td nowrap>Pais al que pertenece: </td>
      <td nowrap><select name="paises1" onChange="javascript: document.getElementById('frm1').submit()">
          <?php
 
if(isset($_POST['paises1'])){ 
	$pa=$_POST['paises1'];
}elseif(isset($_POST['bot'])){ 
	//conocer el numero de pais
	$pa=$reg['cve_pais'];
}
@$sql=mysqli_query($con ,"select * from dxpaises");
while($reg1=mysqli_fetch_array($sql)){
	if($reg1['cve_pais'] == $pa){
		echo '<option value="' . $reg1['cve_pais'] . '" select>' . $reg1['des_pais'] . '</option>';
	}else{
		echo '<option value="' . $reg1['cve_pais'] . '">' . $reg1['des_pais'] . '</option>';
	}
}			
?>
      </select> </td>
    </tr>
    <tr> 
      <td nowrap>Estado al que pertenece: </td>
      <td nowrap><select name="estados">
          <?php

if(isset($_POST['paises1'])){ 
	$es=$_POST['estados'];
}elseif(isset($_POST['bot'])){ 
	$es=$reg['cve_estado'];
}
@$sql=mysqli_query($con ,"select * from dxestado where cve_pais = '$pa'");
while($reg1=mysqli_fetch_array($sql)){
	if($reg1['cve_estado']==$es){
		echo '<option value="' . $reg1['cve_estado'] . '" selected>' . $reg1['des_estado'] . '</option>'; 
	}else{
		echo '<option value="' . $reg1['cve_estado'] . '">' . $reg1['des_estado'] . '</option>'; 
	}
}
?>
      </select> </td>
    </tr>
    <tr>
      <td nowrap>Delegacion / Municipio:</td>
      <td nowrap><select name="tmun">
          <?php

if(isset($_POST['tmun'])){ 
	$mu=$_POST['tmun'];
}elseif(isset($_POST['bot'])){ 
	$mu=$reg['cve_delmun'];
}
@$sql=mysqli_query($con ,"select * from dxdelmun where cve_estado = '$es'");
while($reg1=mysqli_fetch_array($sql)){
	if($reg1['cve_delmun']==$mu){
		echo '<option value="' . $reg1['cve_delmun'] . '" selected>' . $reg1['des_delmun'] . '</option>'; 
	}else{
		echo '<option value="' . $reg1['cve_delmun'] . '">' . $reg1['des_delmun'] . '</option>'; 
	}
}
?>
      </select></td>
    </tr>
<tr>
      <td nowrap> Codigo Postal: </td>
      <td nowrap><input name="tcod" type="text" id="tmun" size="6" maxlength="25" onKeyPress="return validar(event)" <?php
 
if(isset($_POST['tcol'])){ 
	echo ' value="' . $_POST['tcod'] . '"';
}elseif(isset($_POST['bot'])){ 
	echo ' value="' . $reg['cod_pos'] . '"';
}
?>/></td>
    </tr>	
    <tr> 
      <td width="108" nowrap> Colonia: </td>
      <td width="384" nowrap> <input name="tcol" type="text"  size="40" maxlength="25"
<?php
 
if(isset($_POST['tcol'])){ 
	echo ' value="' . $_POST['tcol'] . '"';
}elseif(isset($_POST['bot'])){ 
	echo ' value="' . $reg['des_colonia'] . '"';
}
?>> </td>
    </tr>
    <tr> 
      <td colspan="2"><div align="center">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</div></td>
    </tr>
  </table>
</form>
<?php
 
if(isset($_POST['bot3'])){
	echo '<div align="center">
	<form id="form1" name="form1" action="cat_codigos_PR.php" target="_self">
		<input type="submit" name="submit" value="Regresar">
	</form>
	</div>';
	
}
?>
 </body>
<?php
 
mysqli_close($con);
}
?>
</html>