Foros del Web » Programando para Internet » Javascript »

Recoger datos del formulario.

Estas en el tema de Recoger datos del formulario. en el foro de Javascript en Foros del Web. Compañeros necesito ayuda, tengo 3 archivos donde recojo los datos de un formulario.Me ha funcionado bien hasta hoy que no funciona: index.php Código PHP: <! ...
  #1 (permalink)  
Antiguo 17/09/2012, 16:12
Avatar de satjaen  
Fecha de Ingreso: septiembre-2012
Ubicación: Jaén (Andalucía)
Mensajes: 893
Antigüedad: 11 años, 7 meses
Puntos: 10
Recoger datos del formulario.

Compañeros necesito ayuda, tengo 3 archivos donde recojo los datos de un formulario.Me ha funcionado bien hasta hoy que no funciona:


index.php

Código PHP:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<
html xmlns="http://www.w3.org/1999/xhtml">
<
head>
<
script type="text/javascript" src="assets/js/jquery-1.7.2.min.js"></script>
<script type="text/javascript" src="assets/jqueryui/js/jquery-ui-1.8.16.custom.min.js"></script>
<script type="text/javascript" src="assets/js/js.js"></script>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Documento sin título</title>
<link href="estilo1.css" rel="stylesheet" type="text/css" />
<script src="SpryAssets/SpryTabbedPanels.js" type="text/javascript"></script>
<link href="SpryAssets/SpryTabbedPanels.css" rel="stylesheet" type="text/css" />
  <script> 
function enviar_formulario(){ 
   document.form1.submit() 

</script> 
 <script> 
function enviar_formulario1(){ 
  document.form1.reset();

</script> 
<script> 
function enviar()
{    
var formulario = document.getElementById("");        
var dato = formulario[0];     
if (dato.value=="enviar"){        
alert("Enviando el formulario");        
formulario.submit();        
return true;    
} else {        
alert("No se envía el formulario");        
return false;    }}
</script> 
</head>
<body>
<div id="contenedor">
<div id="cabecera">Consulta de intervenciones</div>
<div id="tabla">
    <div id="formulario">
    <form id="frm_filtro" method="post" action="menu1.php" name="form1">
            <table width="685">
  <tr>
    <td width="9%" class="campo_apellidos2">Teléfonos</td>
    <td width="9%"><input name="telefono" type="text" size="9" /></td>
    <td width="9%"><input name="telefono2" type="text" id="telefono2" size="9" /></td>
    <td width="9%"><input name="telefono3" type="text" id="telefono3" size="9" /></td>
    <td width="32%">&nbsp;</td>
    <td width="18%" class="campo_apellidos2">NIF</td>
    <td width="14%"><input name="NIF" type="text" id="NIF" size="9" /></td>
  </tr>
  <tr>
    <td class="campo_apellidos2">Nombre</td>
    <td colspan="4"><input name="nombre_apellidos" type="text" size="30" />
    <td>&nbsp;</td>
    <td>&nbsp;</td>
  </tr>
  <tr>
    <td class="campo_apellidos2">Localidad</td>
    <td colspan="4"><input name="poblacion" type="text" size="30" />
      <span class="campo_apellidos2">C.Postal</span>      <input name="cod_postal" type="text" id="cod_postal" size="5" /></td>
    <td class="campo_apellidos2">Provincia</td>
    <td><input name="provincia" type="text" size="9" /></td>
  </tr>
  <tr>
    <td class="campo_apellidos2">Calle</td>
    <td colspan="4"><input name="calle" type="text" id="calle" size="45" />
      <span class="campo_apellidos2">Nº</span>      <input name="numero" type="text" id="numero" size="5" /></td>
    <td class="campo_apellidos2">Edificio</td>
    <td><input name="edificio" type="text" id="edificio" size="5" /></td>
  </tr>
  <tr>
    <td class="campo_apellidos2">Puerta</td>
    <td colspan="3"><input name="puerta" type="text" id="puerta" size="5" />
      <span class="campo_apellidos2">      Piso</span>
      <input name="piso" type="text" id="piso" size="5" />
      <span class="campo_apellidos2">Letra</span>        <input name="letra" type="text" id="letra" size="5" /></td>
    <td>&nbsp;</td>
    <td><span class="campo_apellidos2">Nº Mante.</span></td>
    <td><input name="mantenimiento" type="text" id="mantenimiento" size="5" /></td>
  </tr>
  </table>
  <table width="100%">
  <tr>
    <th scope="col"><button type="button"  id="btnfiltrar" name="btnfiltrar" style="border:0; margin:0; padding:0;cursor:pointer">
  <img src="imagenes_menu/boton_buscar.png"/>
</button>
</th>
  </tr>
</table>                
          </form>         
  
    </div>
    <div id="paneles">
      <div id="TabbedPanels1" class="TabbedPanels">
        <ul class="TabbedPanelsTabGroup">
          <li class="TabbedPanelsTab" tabindex="0">Usuarios</li>
          <li class="TabbedPanelsTab" tabindex="0">Aparatos</li>
          <li class="TabbedPanelsTab" tabindex="0">Intervenciones</li>
</ul>
        <div class="TabbedPanelsContentGroup">
          <div class="TabbedPanelsContent">
           <div id="usuario">
            <table width="100%" id="data" class="table-dg-grid" >
             <thead>
              <tr>
       <tr bgcolor=#DFEBFF id=t70 onclick='coloreaf(70,1)' onMouseOver='coloreamosin(70,1)' onMouseOut='coloreamosout(70,1)'>
                    <th><span title="nu_usuario">Nº Usuario</span></th>
                    <th><span title="telefono">Teléfono</span></th>
                    <th><span title="nombre">Nombre</span></th>
                    <th><span title="poblacion">Población</span></th>  
                     </tr>
                </thead>
                <tbody>
                </tbody>
            </table>
                </div>
          </div>
          <div class="TabbedPanelsContent"><table width="100%" id="data1">
           <thead>
  <tr>
                    <th><span title="aparato"></span></th>
                    <th><span title="marca"></span></th>
                    <th><span title="modelo"></span></th>
                    <th><span title="NUM_SERIE"></span></th>
                    <th><span title="num_PRODUCTO"></span></th>
                    <th><span title="FECHA_compra"></span></th>
   </tr>
                </thead>
                <tbody>
                </tbody>
</table>
</div>
          <div class="TabbedPanelsContent">
           
          <table cellpadding="0" cellspacing="0" id="data2">
                <thead>
                  <tr>
                    <th><span title="num_aviso"></span></th>
                    <th><span title="num_usuario"></span></th>
                    <th><span title="aparato"></span></th>
                    <th><span title="calle"></span></th>
                    <th><span title="fecha_recepcion"></span></th>
                    <th><span title="fecha_recepcion"></span></th>
                    <th><span title="sintoma"></span></th>
                  </tr>
                </thead>
                <tbody>
                </tbody>
              </table>            
          </div>
</div>
      </div>
      <table width="100%">
        <tr>
<th scope="col"><a class="" href="javascript:enviar_formulario()"><span></span><img src="imagenes_menu/generar_aviso1.png" width="150" height="40" border="0"/></a>
</th>
          <th scope="col">&nbsp;</th>
          <th scope="col"></th>
          <th scope="col"><a class="" href="javascript:enviar_formulario1()"><span></span><img src="imagenes_menu/boton_salir.png" width="150" height="40" border="0"/></a>
 </th>
        </tr>
      </table>
    </div>
</div>
</div>
<script type="text/javascript">
var TabbedPanels1 = new Spry.Widget.TabbedPanels("TabbedPanels1");
</script>
</body>
</html> 



ajax.php

Código PHP:
<?php 
include("conexion.php");
if (
$_GET["action"] == "listar")
{
    
// valores recibidos por POST
    
$vnm   $_POST['nombre_apellidos'];
    
$vpo $_POST['poblacion'];
    
$vte $_POST['telefono'];
    
$vdel  = ($_POST['del'] != '' ) ? explode("/",$_POST['del']) : '';
    
$val   = ($_POST['al']  != '' ) ? explode("/",$_POST['al']) : '';
    
    
$sql "SELECT U.nombre, U.apellidos, U.nu_usuario, U.telefono, A.aparato, A.marca, A.modelo, A.num_serie, A.num_producto, A.fecha_compra, D.poblacion, D.calle, E.num_aviso, E.num_usuario, E.aparato, E.fecha_recepcion, E.fecha_emision, E.sintoma
FROM dir_usuarios D, usuarios U, ap_usuarios A, avisos E
WHERE U.NU_USUARIO = A.NUM_USUARIO
AND D.USUARIO = U.NU_USUARIO
AND U.NU_USUARIO = E.NUM_USUARIO
AND CONCAT( nombre, ' ', apellidos ) LIKE '%$vnm%'
    AND telefono LIKE '%$vte%'
    AND poblacion LIKE '%$vpo%'"
;     
                                
    
// Ordenar por
    
$vorder $_POST['orderby'];
    
    if(
$vorder != ''){
        
$sql .= " ORDER BY ".$vorder;
    }
    
    
$query mysql_query($sql);
    
$datos = array();
    
    while(
$row mysql_fetch_array($query))
    {
        
$datos[] = array(
            
'nu_usuario'          => $row['nu_usuario'],
            
'telefono'          => $row['telefono'],
            
'nombre'      => $row['nombre'],
            
'apellidos'       => $row['apellidos'],
            
'poblacion'        => $row['poblacion'],
            
'aparato'          => $row['aparato'],
            
'marca'          => $row['marca'],
            
'modelo'      => $row['modelo'],
            
'num_serie'       => $row['num_serie'],
            
'num_producto'        => $row['num_producto'],
            
'fecha_compra'        => $row['fecha_compra'],
            
'num_aviso'          => $row['num_aviso'],
            
'num_usuario'          => $row['num_usuario'],
            
'aparato'      => $row['aparato'],
            
'calle'       => $row['calle'],
            
'fecha_recepcion'        => $row['fecha_recepcion'],
            
'fecha_emision'        => $row['fecha_emision'],
            
'sintoma'        => $row['sintoma']
        );
    }
    
// convertimos el array de datos a formato json
    
echo json_encode($datos);
}

?>

Continua.....
  #2 (permalink)  
Antiguo 17/09/2012, 16:13
Avatar de satjaen  
Fecha de Ingreso: septiembre-2012
Ubicación: Jaén (Andalucía)
Mensajes: 893
Antigüedad: 11 años, 7 meses
Puntos: 10
Respuesta: Recoger datos del formulario.

Y el ultimo:



js.js

Código PHP:

// JavaScript Document
var ordenar '';
$(
document).ready(function(){
    
    
// Llamando a la funcion de busqueda al
    // cargar la pagina
    
filtrar()
    
    var 
dates = $( "#del, #al" ).datepicker({
            
yearRange"-50",
            
defaultDate"+1w",
            
changeMonthtrue,
            
changeYeartrue,
            
onSelect: function( selectedDate ) {
                var 
option this.id == "del" "minDate" "maxDate",
                    
instance = $( this ).data"datepicker" ),
                    
date = $.datepicker.parseDate(
                        
instance.settings.dateFormat ||
                        $.
datepicker._defaults.dateFormat,
                        
selectedDateinstance.settings );
                
dates.notthis ).datepicker"option"optiondate );
            }
    });
    
    
// filtrar al darle click al boton
    
$("#btnfiltrar").click(function(){ filtrar() });
    
    
// boton cancelar
    
$("#btncancel").click(function(){ 
        $(
".filtro input").val('')
        $(
".filtro select").find("option[value='0']").attr("selected",true)
        
filtrar() 
    });
    
    
// ordenar por
    
$("#data th span").click(function(){
        var 
orden '';
        if($(
this).hasClass("desc"))
        {
            $(
"#data th span").removeClass("desc").removeClass("asc")
            $(
this).addClass("asc");
            
ordenar "&orderby="+$(this).attr("title")+" asc"        
        
}else
        {
            $(
"#data th span").removeClass("desc").removeClass("asc")
            $(
this).addClass("desc");
            
ordenar "&orderby="+$(this).attr("title")+" desc"
        
}
        
filtrar()
    });
});
var 
filanull;
function 
pulsar(obj) {
  
obj.style.background 'orange';
  if (
fila != null && fila != obj)
    
fila.style.background 'white';
  
fila obj;
}
function 
filtrar()
{    
    $.
ajax({
        
data: $("#frm_filtro").serialize()+ordenar,
        
type"POST",
        
dataType"json",
        
url"ajax.php?action=listar",
            
success: function(data){ 
    var 
html_user ='' ;
    var 
html_aparato '';
    var 
html_avisos '';
    if(
data.length 0){ 
        $.
each(data, function(i,item){ 
        
        
         
            
html_user += '<tr onclick="pulsar(this)" >';
            
html_user += '<td >'+item.nu_usuario+'</td>';
            
html_user += '<td>'+item.telefono+'</td>';
            
html_user += '<td>'+item.nombre+' '+item.apellidos+'</td>';
            
html_user += '<td>'+item.poblacion+'</td>';
            
html_user += '</tr>';
            
            
            
            
html_aparato += '<tr>';
            
html_aparato += '<td>'+item.aparato+'</td>';
            
html_aparato += '<td>'+item.marca+'</td>'
            
html_aparato += '<td>'+item.modelo+'</td>'
            
html_aparato += '<td>'+item.num_serie+'</td>';
            
html_aparato += '<td>'+item.num_producto+'</td>';
            
html_aparato += '<td>'+item.fecha_compra+'</td>';
            
html_aparato += '</tr>'
            
        
            
            
            
html_avisos += '<tr>';
            
html_avisos += '<td>'+item.num_aviso+'</td>';
            
html_avisos += '<td>'+item.num_usuario+'</td>'
            
html_avisos += '<td>'+item.aparato+'</td>'
            
html_avisos += '<td>'+item.calle+'</td>';
            
html_avisos += '<td>'+item.fecha_recepcion+'</td>';
            
html_avisos += '<td>'+item.fecha_emision+'</td>';
            
html_avisos += '<td>'+item.sintoma+'</td>';
            
html_avisos += '</tr>';    
                                  
        });                     
    } 
    if(
html_user == ''html_user '<tr><td colspan="4" align="center">No se encontraron registros..</td></tr>';
    if(
html_aparato == ''html_aparato '<tr><td colspan="4" align="center">No se encontraron registros..</td></tr>';
    if(
html_avisos == ''html_avisos '<tr><td colspan="4" align="center">No se encontraron registros..</td></tr>';
    $(
"#data tbody").html(html_user); 
    $(
"#data1 tbody").html(html_aparato); 
    $(
"#data2 tbody").html(html_avisos); 
}

            
      });

Muchas gracias.

Etiquetas: ajax, formulario, funcion, html, input, js, php, recoger, select
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 21:32.