Ver Mensaje Individual
  #1 (permalink)  
Antiguo 22/09/2005, 13:47
inglualcaus
 
Fecha de Ingreso: junio-2005
Mensajes: 38
Antigüedad: 18 años, 10 meses
Puntos: 0
Ayuda Urgente

necesito por favor que me colaboren con este codigo en el cual trabajo con dos listbox anidados.. que cargan bien pero tengo antes de estos dos input mas y se conservan cuando se refresca la pagina al utilizar uno de los listbox para que me habilite el otro....
este es el codigo

conexion.php

<? function conectarse() {
if (!($link=@mysql_connect("localhost","root","")))
{ echo "Error conectando a la base de datos.";
exit(); }
if (!(mysql_select_db("obser",$link)))
{ echo "Error seleccionando la base de datos.";
exit(); }
return $link; } ?><?php require_once('conexion.php'); ?>
<?
if(isset($enviartodo))
{
if($ID_CIUDAD)
{
$link=conectarse();
$resp = mysql_query("SELECT * FROM ciudad WHERE ID_CIUDAD='$ID_CIUDAD' AND ID_DEPARTAMENTO='$ID_DEPARTAMENTO' ", $link);
if(mysql_num_rows($resp) != 0 )
{
echo"<script>";
echo 'alert("El Código Que Se Digitó Ya Existe")';
echo"</script>";
}
else{
$sql="insert into ciudad(ID_CIUDAD,NOM_CIUDAD,ID_DEPARTAMENTO) values ('$ID_CIUDAD','$NOM_CIUDAD','$id_hija')";
mysql_query($sql,$link);
echo"<script>";
echo'alert("Registro Insertado Con Exito!!!")';
echo"</script>";
}
}
}
?>

prueba.php
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>Documento sin t&iacute;tulo</title>

<style type="text/css">
<!--
.Estilo3 {font-family: Arial, Helvetica, sans-serif}
-->
</style>

<script>
//ESTA SIRVE
function validacion(f) {
// VALIDA EL FORMULARIO ANTES DE ENVIARLO//
var er_nombre = /^([a-z]|[A-Z]|á|é|í|ó|ú|ñ|ü|\s)+$/; //letras, '.' y '-' o vacio
var n = Math.round(f.ID_CIUDAD.value);
var nint= parseInt(f.ID_CIUDAD.value);
var nflo= parseFloat(f.ID_CIUDAD.value);

if(f.ID_CIUDAD.value >9999){
alert("¡ El campo código No debe ser mayor de 9999 !");
f.ID_CIUDAD.value="";
f.ID_CIUDAD.focus();
return false;
}

if(f.ID_CIUDAD.value==""){
alert("¡ El campo código No debe estar vacio !");
f.ID_CIUDAD.value="";
f.ID_CIUDAD.focus();
return false;
}
if( n==0 || isNaN(n) || nint!=nflo || f.ID_CIUDAD.value==isNaN(n)){
alert("¡ El campo código Debe ser un número entero !");
f.ID_CIUDAD.value="";
f.ID_CIUDAD.focus();
return false;
}
if(!er_nombre.test(f.NOM_CIUDAD.value)) {
alert('¡ El campo nombre de usuario No es valido !');
f.NOM_CIUDAD.value = "";
f.NOM_CIUDAD.focus();
return false;
}

if(f.ID_CIUDAD.value=="" || f.NOM_CIUDAD.value==""){
alert("¡ NO DEBE HABER CAMPOS VACIOS!");
return false;
}


return true;

}
</script>
</head>

<body topmargin="0" leftmargin="0">

<script language="JavaScript1.2">mmLoadMenus();</script>

<center>
<!--DWLayoutTable-->
<table border="0" cellpadding="0" cellspacing="0" width="776" background="../images/fondo.jpg">
<?
$link=conectarse();

?>
<!--DWLayoutTable-->
<!-- fwtable fwsrc="modelo_admin.png" fwbase="obser" fwstyle="Dreamweaver" fwdocid = "688209807" fwnested="1" -->
<tr>
<td width="776"><img name="n1" src="../images/1.jpg" width="776" height="101" border="0" alt=""></td>
</tr>
<tr>
<td><img name="n2" src="../images/2.jpg" width="776" height="27" border="0" alt=""></td>
</tr>
<tr>
<td height="746" valign="top"><table width="100%" border="0" cellpadding="0" cellspacing="0">
<!--DWLayoutTable-->
<tr>
<td width="190" rowspan="4" valign="top"><table width="100%" border="0" cellpadding="0" cellspacing="0">
<!--DWLayoutTable-->
<tr>
<td width="190" height="208" valign="top"><img name="n3" src="../images/3.jpg" width="190" height="208" border="0" usemap="#m_3" alt="">
</td>
</tr>
</table></td>
<td height="40" colspan="3" valign="top"><table background="../images/4.jpg" width="100%" border="0" cellpadding="0" cellspacing="0">
<!--DWLayoutTable-->
<tr>
<td width="586" height="40">&nbsp;</td>
</tr>
</table></td>
</tr>
<tr>
<td width="73" height="39">&nbsp;</td>
<td width="445" valign="top"><table width="100%" border="0" cellpadding="0" cellspacing="0">
<!--DWLayoutTable-->
<tr>
<td width="445" height="39" valign="middle"><div align="center"><strong><span class="Estilo3">REGISTRO DE CIUDADES </span></strong></div></td>
</tr>
</table></td>
<td width="68">&nbsp;</td>
</tr>
<tr>
<td height="255"></td>
<td valign="top"><table width="100%" height="254" border="1"cellpadding="0" cellspacing="0" bordercolor="#DDDDDD">
<!--DWLayoutTable-->
<tr>
<td width="441" height="254" valign="top"><p>&nbsp;</p>
<?
if(isset($_POST['id_padre'])){
$id_padre=$_POST['id_padre'];
}
if(isset($_POST['id_hija'])){
$id_hija=$_POST['id_hija'];
}
?>
<form method="post" name="form1" action="prueba.php" onSubmit="return validacion(this);">
<table align="center" cellpadding="3" cellspacing="3">
<tr valign="baseline">
<td nowrap align="right"><div align="left"><span class="Estilo3">C&oacute;digo:</span></div></td>
<td><input type="text" name="ID_CIUDAD" id= "ID_CIUDAD" value="" size="32"></td>
</tr>
<tr valign="baseline">
<td nowrap align="right"><div align="left"><span class="Estilo3">Nombre:</span></div></td>
<td><input type="text" name="NOM_CIUDAD" value="" size="32"></td>
</tr>
<tr valign="baseline">
<td nowrap align="right"><div align="left"><span class="Estilo3">Pais:</span></div></td>
<td>
<select name="id_padre" onChange="this.form.id_hija.options.selectedIndex=-1;this.form.submit();" size="1" id="id_padre">
<option value="\">- - - Seleccione un Pais - - -</option>
<?

$link=conectarse();
$SQLconsulta_padre="SELECT * FROM pais";
$consulta_padre= mysql_query($SQLconsulta_padre,$link) or died (mysql_error());
while($registro_padre= mysql_fetch_assoc($consulta_padre)){
if($id_padre==$registro_padre['ID_PAIS']){
echo"<option value\"".$registro_padre['ID_PAIS']."\"
selected>".$registro_padre['NOM_PAIS']."</option>";
}else{
echo"<option
value=\"".$registro_padre['ID_PAIS']."\">".$registro_padre['NOM_PAIS']."</option>";
}
}
?>
</select>
<? mysql_free_result($consulta_padre);
?>
</td>
</tr>
<tr valign="baseline">
<td nowrap align="right"><div align="left"><span class="Estilo3">Departamento:</span></div></td>
<td>
<select name="id_hija" size="1" id="id_hija">

<?
$link=conectarse();
if(!empty($id_padre)){
$SQLconsulta_hija="SELECT * FROM departamento WHERE ID_PAIS='$id_padre'";
$consulta_hija= mysql_query($SQLconsulta_hija,$link) or died (mysql_error());
if(mysql_num_rows($consulta_hija) != 0){
while($registro_hija=mysql_fetch_assoc($consulta_h ija)){
if($id_hja==$registro_hija['ID_DEPARTAMENTO']){
echo"<option value=\"".$registro_hija['ID_DEPARTAMENTO']."\"selected>".$registro_hija['NOM_DEPTO']."</option>";
}else{
echo"<option value=\"".$registro_hija['ID_DEPARTAMENTO']."\">".$registro_hija['NOM_DEPTO']."</option>";
}
}
}else{
echo"<option value=\"\">NO HAY REGISTROS PARA ESE ITEM </option>";
}
}else{
echo"<option value=\"\"><--Seleccione un item </option>";
}
mysql_free_result($consulta_padre);
?>
</select>
</td>
</tr>
</table>
<p align="center">
<input type="hidden" name="enviartodo" value="1">
<input type="submit" name="Submit" value="Registrar">
&nbsp;
<INPUT name="reset" TYPE="reset" value="Borrar datos">
</p>
</form>
</td>
</tr>
</table></td>
<td></td>
</tr>
</table></td>
</tr>

</table>

</center>
</body>
</html>