Foros del Web » Programando para Internet » Javascript » Frameworks JS »

Ventana modal

Estas en el tema de Ventana modal en el foro de Frameworks JS en Foros del Web. Hola a todos tengo el siguiente problema, hago una ventana modal con el siguiente codigo, en el cual cargo un formulario para dar de alta ...
  #1 (permalink)  
Antiguo 13/11/2011, 19:42
 
Fecha de Ingreso: febrero-2009
Ubicación: mexico
Mensajes: 148
Antigüedad: 15 años, 2 meses
Puntos: 1
Pregunta Ventana modal

Hola a todos tengo el siguiente problema, hago una ventana modal con el siguiente codigo, en el cual cargo un formulario para dar de alta en una tabla de mi bd, en la misma pagina donde se hace la ventana modal, tengo una tabla que me muestra los registros insertados en la bd, como la siguiente

Código PHP:
<table>
   <tr>
       <td>NOMBRE</td>
       <td>DOMICILIO</td>
   </tr>
<?php
for($i=0;$i<$total;$i++)
{
    
$id $lista[$i]['id'];
    
$nombre $lista[$i]['nombre'];
    
$domicilio $lista[$i]['domicilio'];
?>
<tr>
<td><?php echo $nombre;?></td>
<td><?php echo $domicilio;?></td>
<td><a href="modificar.php?id=<?php echo $id;?>">Modificar</a></td>
</tr>
<?php
}
?>
</table>
ahora lo que yo necesito y quiero hacer y no he podido resolver es hacer una ventana modal para cada registro, al momento de dar clic me abra una ventana modal con el formulario para poder modificar los datos, pero no se como hacerlo, la ventana modal que muestra el formulario de alta es la siguiente

modal.css
<style>
#mask {
position:absolute;
left:0;
top:0;
z-index:9000;
background-color:#000;
display:none;
}

#boxes .window {
position:fixed;
left:0px;
margin-top: -10px;
width:200px;
height:100px;
display:none;
z-index:9999;
padding:20px;
overflow: scroll;
}

#boxes #dialog {
width:900px;
height:550px;
margin-left: 0px;
background-color:#ffffff;
}
.close{
margin-right: 0;
font-size: 12px;
}
</style>


modal.js
<script>
$(document).ready(function() {

//select all the a tag with name equal to modal
$('#modal').click(function(e) {
//Cancel the link behavior
e.preventDefault();

//Get the A tag
var id = $(this).attr('value');

//Get the screen height and width
var maskHeight = $(document).height();
var maskWidth = $(window).width();

//Set heigth and width to mask to fill up the whole screen
$('#mask').css({'width':maskWidth,'height':maskHei ght});

//transition effect
$('#mask').fadeIn(1500);
$('#mask').fadeTo("slow",0.8);

//Get the window height and width
var winH = $(window).height();
var winW = $(window).width();

//Set the popup window to center
$(id).css('top', winH/2-$(id).height()/2);
$(id).css('left', winW/2-$(id).width()/2);

//transition effect
$(id).fadeIn(1500);

});

//if close button is clicked
$('.window .close').click(function (e) {
//Cancel the link behavior
e.preventDefault();

$('#mask').fadeOut(1500);
$('.window').fadeOut(500);
});

//if mask is clicked
$('#mask').click(function () {
$(this).fadeOut();
$('.window').fadeOut(1000);
});

});
</script>

lo utilizo asi


Código HTML:
<div id="boxes">
<div id="dialog" class="window curved">
<div id="main">
<form name="forma" action="alta.php">
NOMBRE<input type="text" name="nombre" />
DOMICILIO<input type="text" name="domicilio" />
<input type="submit" name="guardar" />
</form>
</div>
</div>
<div id="mask">
</div>
</div> 
Gracias de antemano a los que me ayuden a resolver este problema
  #2 (permalink)  
Antiguo 15/11/2011, 08:31
Avatar de linuxzero  
Fecha de Ingreso: noviembre-2011
Ubicación: Argentina
Mensajes: 778
Antigüedad: 12 años, 5 meses
Puntos: 160
Respuesta: Ventana modal

Si te interesa podes, utilizar este plugin de jQuery que te permite hacer un modal de un formulario tan solo indicandole en el atributo message del metodo del modal el id del formulario.

Aca te dejo el link: http://jquery.malsup.com/block/

Sirve banda, yo lo uso para varios de los sistemas que desarrollé.

Cualquier cosa chiflá!

Saludos!
__________________
Si todo fuera tan sencillo como un symfony cc la vida seria más fácil.
http://phpnico.wordpress.com
  #3 (permalink)  
Antiguo 16/11/2011, 00:10
 
Fecha de Ingreso: febrero-2009
Ubicación: mexico
Mensajes: 148
Antigüedad: 15 años, 2 meses
Puntos: 1
Respuesta: Ventana modal

Gracias bro, me podría ayudar para poder implementarlo en la tabla así como lo indico arriba
  #4 (permalink)  
Antiguo 16/11/2011, 05:29
Avatar de linuxzero  
Fecha de Ingreso: noviembre-2011
Ubicación: Argentina
Mensajes: 778
Antigüedad: 12 años, 5 meses
Puntos: 160
Respuesta: Ventana modal

Si deberia sin problemas, en el atributo message solo deberias indicarle $('#boxex'). Con eso debería bastar.

Cualquier problema avisame ;)

Saludos!
__________________
Si todo fuera tan sencillo como un symfony cc la vida seria más fácil.
http://phpnico.wordpress.com

Etiquetas: jquery
Atención: Estás leyendo un tema que no tiene actividad desde hace más de 6 MESES, te recomendamos abrir un Nuevo tema en lugar de responder al actual.
Respuesta




La zona horaria es GMT -6. Ahora son las 17:55.