Ver Mensaje Individual
  #15 (permalink)  
Antiguo 26/09/2012, 10:37
nataliagb1992
 
Fecha de Ingreso: septiembre-2012
Ubicación: Sevilla
Mensajes: 144
Antigüedad: 11 años, 7 meses
Puntos: 0
Respuesta: refrscar un formulario con ajax

sigue sin salir esque no estiendo prque , estos e esta empeñando en estropearme el dia , pos oy me tiene que salir , aver si ves el fallo esque ni se inmuta , meto el cdigo de barras y nada no aparece nada ni un cuadraito ni un na : mira te paso las dos pagians de nuevo aver si tu encuentars algo poruqe yo ya no veo naaaaa:

Código HTML:
Ver original
  1. [HIGHLIGHT="PHP"]pagina 1
  2.  
  3. <?php
  4. header("Content-Type: text/html;charset=utf-8");
  5. ?>
  6. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
  7. <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="es" lang="es">
  8.     <head>
  9.         <title>Entrada de Almacen</title>
  10.         <meta http-equiv="content-type" content="text/html; charset=utf-8" />
  11.         <meta http-equiv="Content-Style-Type" content="text/css" />
  12.         <link rel="shortcut icon" href="/favicon.ico" type="image/x-icon" />
  13.         <link rel="stylesheet" type="text/css" media="screen" href="cssPageGrid.css" />
  14.         <link rel="stylesheet" type="text/css" media="screen" href="tema/css/custom-theme/jquery-ui-1.8.23.custom.css" />
  15.         <link rel="stylesheet" type="text/css" media="screen" href="css/ui.jqgrid.css" />
  16.         <link rel="stylesheet" type="text/css" media="screen" href="css/ui.multiselect.css" />
  17.  
  18.         <script src="js/jquery.min.js" type="text/javascript"></script>
  19.         <script src="js/jquery-ui-custom.min.js" type="text/javascript"></script>
  20.         <script src="js/jquery.layout.js" type="text/javascript"></script>
  21.         <script src="js/i18n/grid.locale-es.js" type="text/javascript"></script>
  22.         <script type="text/javascript">
  23.             $.jgrid.no_legacy_api = true;
  24.             $.jgrid.useJSON = true;
  25.         </script>
  26.         <script src="js/ui.multiselect.js" type="text/javascript"></script>
  27.         <script src="js/jquery.jqGrid.min.js" type="text/javascript"></script>
  28.         <script src="js/jquery.tablednd.js" type="text/javascript"></script>
  29.         <script src="js/jquery.contextmenu.js" type="text/javascript"></script>
  30.     </head>
  31.     <body>
  32.         <div id="formularioArt">
  33.             <form action="entradaArticulo.php" method="post">
  34.                 <legend>Entrada Almacén</legend>
  35.                 <br/>
  36.                 <label>Código de Barras</label>
  37.                 <input name="cBar" id="cBar" type="text" size="20" maxlenght="200" autofocus/>
  38.                 <br/>
  39.                 <label>Fecha Entrada:</label>
  40.                 <script>
  41.                     $(function() {
  42.                         $( "#fechaFactura" ).datepicker({
  43.                             showOtherMonths: true,
  44.                             selectOtherMonths: true,
  45.                             dateFormat:'dd/mm/yy',
  46.                             firstday:1
  47.                         });  
  48.                         $('#fecha').datepicker($.datepicker.regional['es']);                                  
  49.                     });
  50.                 </script>
  51.                 <input type="text" id="fechaFactura" name="fechaFactura" maxlenght="5" />
  52.                 <br/>
  53.  
  54.                 <label>Nº de Serie:</label>
  55.                 <input name="numSer" id="numSer" type="text" size="30" maxlenght="200"/><br/>
  56.                 <script>
  57.                    $(document).ready(function(){
  58.                         $('#cBar').keydown(function(event){
  59.                             if (event.which == 13) {
  60.                                 $.ajax({
  61.                                     url: 'ajax.php',
  62.                                     type: 'POST',
  63.                                         data: 'cBar=' + $(this).val(),
  64.                                     success: function(data){
  65.                                         $('resultado').val(data);
  66.                                     }
  67.                                 });
  68.                                 event.preventDefault();
  69.                             }
  70.                         });
  71.                     });
  72.     /* function ajax(cBar){
  73.      $.post("ajax.php",{cBarras:cBar},function(respuesta){
  74.         jQuery("#resultado").html(respuesta);
  75.     });
  76.     }*/
  77.    
  78.                 </script>
  79.                 <div id="resultado"></div>
  80.              
  81.                 <input id="enviar" name="enviar" type="submit" value="Aceptar" />
  82.             </form>
  83.         </div>
  84.  
  85.     </body>
  86. </html>
[/HIGHLIGHT]

pagina 2:


Código PHP:
Ver original
  1. <?php
  2. header("Content-Type: text/html;charset=utf-8");
  3. /* al rellenar el codigo de barras se nos muestra la informacion del producto
  4.  * http://www.forosdelweb.com/f13/ajax-php-conectada-con-resultados-base-datos-1015007/
  5.  */
  6. include_once 'clases/Class_Bd.php';
  7. echo  " <link rel='stylesheet' type='text/css' media='screen' href='cssPageGrid.css' />";
  8.  
  9. $conexion = new Conecta_DB;
  10. $conexion->conectar();
  11. $res = $_POST['cBar'];
  12. echo "la variable es :".$res;
  13. $consulta = "SELECT nombre,descripcion,familia FROM altaArticulos WHERE cBarras='$res'";
  14.  
  15. $query = $conexion->consultar($consulta);
  16. echo "<tabla id='tabla'>
  17.        <tr>
  18. <td id='td1'>Nombre del Producto</td><td id='td1'>Descripción del Producto</td><td id='td1'>Familia del Producto</td>
  19. </tr> <tr>" ;
  20.  
  21. foreach($query as $row){
  22.     echo "<td>";
  23.     echo $row[0]['nombre'];
  24.     echo "</td><td>";
  25.     echo $row[0]['descripcion'];
  26.     echo "</td><td>";
  27.     echo $row[0]['familia'];
  28. }
  29. echo"</tr></table>";
  30. /*while ($row = mysql_fetch_array($query)) {
  31.     $aviso0 = $row[0]['nombre'];
  32.     $aviso1 = $row[0]['descripcion'];
  33.     $aviso2 = $row[0]['familia'];
  34.     $aviso = "Articulo " . $aviso0 . "con la descripción " . $aviso1 . "que pertenece a la familia " . $aviso2 . ".";
  35.     print "<textarea id='resultado'>" . $aviso . "</textarea>";
  36. }*/
  37. ?>