Ver Mensaje Individual
  #1 (permalink)  
Antiguo 15/09/2014, 14:12
robertocarrillo
 
Fecha de Ingreso: septiembre-2014
Mensajes: 79
Antigüedad: 9 años, 7 meses
Puntos: 0
forms y check

Hola, es la primera vez que posteo, espero poder ser claro.
Tengo una base mysql la cual cargo y consulto a traves de mis php.
En uno archivo php tengo un serie de carga de datos donde, con un checkbx muestro u oculto unos campos:
Código PHP:
<html><head>
<
script>
$(
document).ready(function(){
   $(
"#responsable").click(function(evento){
      if ($(
"#responsable").attr("checked")){
         $(
"#resp").css("display""inline");
      }else{
         $(
"#resp").css("display""none");
      }
   });
});
</script>
</head>
<body>
<form action="g_t.php" method="post">
<label>Apellido: </label><input style="width:110px" type="text" name="apellido"/> 
<label>Nombre: </label><input style="width:110px" type="text" name="nombre"/>
<label>D. N. I.: </label><input style="width:100px" type="text" name="dni"/> 
<label>Domicilio: </label><input style="width:110px" type="text" name="domicilio"/>
<label>Localidad: </label><input style="width:110px" type="text" name="localidad"/><br>
<label>Responsable Legal</label><input type="checkbox" id="responsable"  name="resposnsable" value="1">
<br>
<div style="display:none;" id="resp">
<label>Apellido: </label> <input style="width:110px;" type="text" name="resp_apellido"/> 
<label>Nombre: </label>   <input style="width:110px;" type="text" name="resp_nombre"/> 
<label>D. N. I.: </label> <input style="width:100px;" type="text" name="resp_dni"/> 
<label>Domicilio: </label><input style="width:110px;" type="text" name="resp_domicilio"/>
<label>Localidad: </label><input style="width:110px;" type="text" name="resp_localidad"/>
</div>
<input type="submit"/>
</form>
</body></html> 
Hasta ahí todo bien, pero cuando consulto y me traigo los valores guardados en la tabla el script no me funciona (si funciona haciendo 2 clicks en el check)y por lo tanto no me deja ver los campos con datos ocultos por defecto...

Código PHP:
<?
$datos 
=$_REQUEST["mod"];
$dat=explode("/",$datos);
$causa=$dat[0];
$sector=$dat[1];
$modi=mysql_query("select * from acta_".$sector." WHERE nro_causa=".$causa.";",$conexion);
$rst_modimysql_fetch_array($modi);
?>
<html><head>
<script>
$(document).ready(function(){
   $("#responsable").click(function(evento){
      if ($("#responsable").attr("checked")){
         $("#resp").css("display", "inline");
      }else{
         $("#resp").css("display", "none");
      }
   });
});
</script>
</head>
<body>
<form action="g_m_t.php" method="post">
<div>
<label>Apellido: </label><input style="width:110px" type="text" name="apellido" value="<?php echo $rst_modi["apellido"];?>"/> 
<label>Nombre: </label><input style="width:110px" type="text" name="nombre" value="<?php echo $rst_modi["nombre"];?>"/> 
<label>D. N. I.: </label><input style="width:100px" type="text" name="dni" value="<?php echo $rst_modi["dni"];?>"/> 
<label>Domicilio: </label><input style="width:110px" type="text" name="domicilio" value="<?php echo $rst_modi["domicilio"];?>"/>
<br>
<label>Responsable Legal</label><input type="checkbox" id="responsable"  name="resposnsable" <?php if($rst_modi["responsable"]=="1") echo 'checked';?> value="1">
<br>
<div style="display:none;" id="resp">
<label>Apellido: </label> <input style="width:110px;" type="text" name="resp_apellido" value="<?php echo $rst_modi["resp_apellido"];?>"/> 
<label>Nombre: </label>   <input style="width:110px;" type="text" name="resp_nombre" value="<?php echo $rst_modi["resp_nombre"];?>"/> 
<label>D. N. I.: </label> <input style="width:100px;" type="text" name="resp_dni" value="<?php echo $rst_modi["resp_dni"];?>"/> 
<label>Domicilio: </label><input style="width:110px;" type="text" name="resp_domicilio" value="<?php echo $rst_modi["resp_domicilio"];?>"/>
<label>Localidad: </label><input style="width:110px;" type="text" name="resp_localidad" value="<?php echo $rst_modi["resp_localidad"];?>"/>
</div>
<input type="submit"/>
</form>
</body></html>
Hay forma que esto funcione? Desde ya muchísimas gracias.