Foros del Web » Programando para Internet » PHP »

[SOLUCIONADO] modal

Estas en el tema de modal en el foro de PHP en Foros del Web. Estimados necesito de su ayuda nuevamente resulta que tengo el siguiente codigo el cual me abre un modal para editar una fila especifica con este ...
  #1 (permalink)  
Antiguo 20/11/2017, 21:33
Avatar de luissquadrito  
Fecha de Ingreso: agosto-2012
Ubicación: en algun lugar de chile
Mensajes: 119
Antigüedad: 11 años, 7 meses
Puntos: 0
modal

Estimados necesito de su ayuda nuevamente resulta que tengo el siguiente codigo

el cual me abre un modal para editar una fila especifica con este codigo

Código PHP:
<html lang="en">

<head>

       <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <meta name="description" content="">
    <meta name="author" content="">

    <title>Boleta de Retencion</title>

    <!-- Bootstrap Core CSS -->
    <link href="css/bootstrap.min.css" rel="stylesheet">

    <!-- Theme CSS -->
    <link href="css/clean-blog.min.css" rel="stylesheet">
    <link href="css/estilo.css" rel="stylesheet">
    <!-- Custom Fonts -->
    <link href="font-awesome/css/font-awesome.min.css" rel="stylesheet" type="text/css">
    <link href='https://fonts.googleapis.com/css?family=Lora:400,700,400italic,700italic' rel='stylesheet' type='text/css'>
    <link href='https://fonts.googleapis.com/css?family=Open+Sans:300italic,400italic,600italic,700italic,800italic,400,300,600,700,800' rel='stylesheet' type='text/css'>

    <script src="js/jquery.js" type="text/javascript"></script>
    <link href="http://netdna.bootstrapcdn.com/bootstrap/3.0.3/css/bootstrap.min.css" rel="stylesheet">
    <script src="http://cdnjs.cloudflare.com/ajax/libs/jQuery-Validation-Engine/2.6.4/jquery.validationEngine.min.js"></script>
  
    <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css">
    <script src="https://code.jquery.com/jquery-1.12.4.min.js"></script>
    <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js"></script>
    <!-- HTML5 Shim and Respond.js IE8 support of HTML5 elements and media queries -->
    <!-- WARNING: Respond.js doesn't work if you view the page via file:// -->
    <!--[if lt IE 9]>
        <script src="https://oss.maxcdn.com/libs/html5shiv/3.7.0/html5shiv.js"></script>
        <script src="https://oss.maxcdn.com/libs/respond.js/1.4.2/respond.min.js"></script>
    <![endif]-->
<script type="text/javascript">
var nav4 = window.Event ? true : false;
function acceptNum(evt){
var key = nav4 ? evt.which : evt.keyCode;
return (key <= 44 || (key >= 48 && key <= 57));
}
</script>  

<script type="text/javascript">
$(document).ready(function (e){
 $('#modal-container-2708').on('show.bs.modal',function(e){
 var id = $(e.relatedTarget).data().id;
 var result=$.ajax({
 type:"POST",data:$("#modal-container-2708").serialize(),
 url:'cursor.php',
 data:'id='+id,
 dataType:'text',
 async:false
 }).responseText;
 document.getElementById("datacurso").innerHTML=result;
 });
});
</script>

</head>
<body>

<?php
if (empty($_POST))
{ echo 
'
 <div class="bg-danger text-center">
 <p><span class="fa fa-times" aria-hidden="true"></span> No indicó que desea observar.</p>
 </div>'
;
die();
}
include 
'conexion_1.php'# conexión base de datos
$id $_POST["id"];
?>
    <form name="vamos" method="GET" action="pico.php">
<div class="col-md-12 text-center">
        <table id="tblprod" class="table table-hover table-bordered">
            <thead>
            <tr>
                                                  <th>Nombre Mercancia</th>
                                                  <th>Descripci&oacute;n Unidad</th>
                                                  <th>Total Unidades</th>
                                                  <th id="total">Peso</th>
                                                  <th id="total">N° Bulto</th>
                                                  <th>Descripci&oacute;n</th>
                                                  <th>Guardar</th>
                                                  
            </tr>
      
            </thead>
            <?php
            $totalpeso
="0";
            
$totalbulto="0";
             
$resultado1 mysql_query("SELECT * FROM mercancia WHERE id = '$id'");
             while (
$row1 mysql_fetch_array($resultado1)){
            
            
             
?>
                                          <tbody>
        <?php
                                
echo "<tr>";
                                echo 
"<td>";
                               
?>
                                <input class="form-control" type="text" name="cantidad1" id="cantidad1" value="<?php echo $row1["cantidad"]; ?>"    
                                <?php
                                
echo "</td>";
                                echo 
"<td>";
                                
?>
                                <input class="form-control"  type="text" name="tipo1" id="tipo1" value="<?php echo $row1["tipo"];?>"    
                                <?php
                                
echo "</td>";
                                echo 
"<td>";
                                
?>
                                <input class="form-control"  type="text" name="contenido1" id="contenido1" value="<?php echo $row1["contenido"];?>"    
                                <?php
                                
echo "</td>";
                                echo 
"<td id='total'´>";
                                
?>
                                <input class="form-control"  type="text" name="peso1" id="peso1" value="<?php echo $row1["peso"];?>"    
                                <?php
                                
echo "</td>";
                                echo 
"<td id='total'´>";
                                
?>
                                <input class="form-control"  type="text" name="bulto1" id="bulto1" value="<?php echo $row1["bulto"];?>"    
                                <?php
                                
echo "</td>";
                                echo 
"<td id='izq'>";
                                
?>
                                <textarea class="form-control"  name="descripcion" id="descripcion1"><?php echo $row1["descripcion"];?></textarea>
                                <?php
                                
echo "</td>";
                                echo 
"<td>";
                                echo 
"<input type='submit' value='guardar'/>";
                                echo 
"<center><a href='#' onClick='url6()'><img width='20px' class='img-responsive' src='img/Save.png'/></a></center>";
                                echo 
"</td>";
                                
                                
                                
$totalpeso=$row1["peso"]+$totalpeso;
                                
$totalbulto=$row1["bulto"]+$totalbulto;
             }
                                
?>
              </tbody>
        </table>
</div>
        </form>    
</body>
<script>   
function url6(){
           
    var valor1 = $("#cantidad1").val();
    var valor2 = $("#tipo1").val();
    var valor3 = $("#contenido1").val();
    var valor4 = $("#descripcion1").val();
    var valor5 = $("#fecha").val();
    var valor6 = $("#rut").val();
    var valor7 = $("#peso1").val();
    var valor9 = $("#bulto1").val();
    
    
    var valores = '?';
      if(valor1!='seleccione'){
        valores += 'cantidad1='+valor1;
      }
      if(valor2!='seleccione'){
        valores += '&tipo1='+valor2;
      }
      if(valor3!='seleccione'){
        valores += '&contenido1='+valor3;
      }
      if(valor4!='!EMPTY'){
        valores += '&prod1='+valor4;
      }
      if(valor5!='!EMPTY'){
        valores += '&fecha1='+valor5;
      }
      if(valor6!='!EMPTY'){
        valores += '&rut1='+valor6;
      }
      if(valor7!='!EMPTY'){
        valores += '&peso1='+valor7;
      }
    
      if(valor9!='seleccione'){
        valores += '&bulto1='+valor9;
      }
      
    var url = 'update3.php'+valores; 
    
     
    if(confirm("¿Desea Actualizar la Mercancia?"))
        
    window.location.href=url;
    else
    window.back;
   }
   
</script>

</html>
el problema es que no se como pasar esos valores para despues editarlos en la base de datos, como pueden ver aregre un boton submit y no funciona, agregue una etiqueta a con un onclick para enviarlo por javascript y no funciona no se como puedo tomar esos valores del modal para que se editen en la BD y se muentres en la primera pagina que esta el codigo a la vista

Quedo atento a sus comentarios amigos
  #2 (permalink)  
Antiguo 21/11/2017, 12:03
Avatar de Triby
Mod on free time
 
Fecha de Ingreso: agosto-2008
Ubicación: $MX->Gto['León'];
Mensajes: 10.106
Antigüedad: 15 años, 8 meses
Puntos: 2237
Respuesta: modal

De entrada, el formulario tiene método GET y en PHP buscas la información en POST. Te sugiero primero hacerlo funcionar sin AJAX para que encuentres y corrijas los posibles errores; después te será más fácil agregar esa funcionalidad.
__________________
- León, Guanajuato
- GV-Foto
  #3 (permalink)  
Antiguo 21/11/2017, 21:22
Avatar de luissquadrito  
Fecha de Ingreso: agosto-2012
Ubicación: en algun lugar de chile
Mensajes: 119
Antigüedad: 11 años, 7 meses
Puntos: 0
Respuesta: modal

ya lo solucione solo bastaba con poner el codigo Javascript en la ventana padre y listo :)

Etiquetas: html, modal, mysql, nombre, select, tabla
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:18.