Foros del Web » Programando para Internet » PHP »

Combobox

Estas en el tema de Combobox en el foro de PHP en Foros del Web. Hola tengo un problemilla y necesito urgentemente ayuda tengo un combo y necesito cada vez que lo seleccione se me actualice un campo cantidad que ...
  #1 (permalink)  
Antiguo 18/12/2008, 09:40
 
Fecha de Ingreso: noviembre-2008
Mensajes: 43
Antigüedad: 15 años, 5 meses
Puntos: 0
Combobox

Hola tengo un problemilla y necesito urgentemente ayuda
tengo un combo y necesito cada vez que lo seleccione se me actualice un campo cantidad que tengo de bajo, para ubicarlos mejor en el combo muestro tecnicos y debajo quisiera mostrar la cantidad de reportes que estan atendiendo, pero no logro coger el id del combo cuando cambio la seleccion, solo lo coge la primera vez y si mando a recargar la pagina vuelve a tomar el indice 0 que es fijo Seleccione el tecnico por favor miren todo el codigo de mi pagina y necesito sugerencias o me volvere loca
Código PHP:
<?php
 
if(!isset($_SESSION))
 
session_start(); 
 if (!isset(
$_SESSION['MM_Username'])){
   
header("location:login.php");
   exit;
 } 
?>
<?php
if(isset($_POST['nombre'])&& isset($_POST['select']))
{
  include(
'clases.php');
  
$temp= new Reportes();
  
$temp->Connection('localhost','reportesphp','root','');
  
$temp->AsignarTecnico($_POST['select']);
  
header("location:AsignarReporte.php");}
?>
<?php
  
//$seleccionado=$_POST['select'];
function Cantidad($seleccionado) {
  if (
$seleccionado!=0)
  {
  
$temp= new Reportes();
  
$temp->Connection('localhost','reportesphp','root','');
  
$cantidad=$temp->ReportesAsignados($seleccionado);
  return 
$cantidad;
    }
    }  
?>
<!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">
<!-- DW6 -->
<head>
<!-- Copyright 2005 Macromedia, Inc. All rights reserved. -->
<!-- TemplateBeginEditable name="doctitle" -->
<title>P&aacute;gina principal</title>
<!-- TemplateEndEditable -->
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<link rel="stylesheet" href="../Style CSS/mm_training.css" type="text/css" />

    </table>    </td>
    <td width="25" valign="top"><img src="../images/mm_spacer.gif" alt="" width="25" height="1" border="0" /></td>
    <td colspan="3" valign="top" bgcolor="#D3DCE6">
    
    <!-- TemplateBeginEditable name="EdtRgnPrincipal" -->
       
        
        <p class="pageName">Asignar Reporte a T&eacute;cnico</p>
        
            
            <form name="frm_Asignar" id="frm_Asignar" method="post">
<table width="100%">
  <tr>     
    <th width="28%" align="right" valign="baseline" class="Estilo1" scope="col">T&eacute;cnico:</th>
    <th width="1%" scope="col"><label for="select"></label></th>
    <th width="24%" align="left" valign="baseline" scope="col"><select name="select" size="1" class="bodText" id="select" tabindex="1" onChange="frm_cant.submit();">
      
      <option value="0">Seleccione el t&eacute;cnico</option>
      <?php
      
 
include('clases.php');
 
$temp=new Reportes();
 
$temp->Connection('localhost','reportesphp','root',''); 
 
$query_rsTecnicos "SELECT id_usuario,nombre_usuarioTec FROM t_usuario WHERE id_privilegio='3'";
 
$rsTecnicos=$temp->SeleccionarDatos$query_rsTecnicos);
 
$row_rsTecnicos mysql_fetch_assoc$rsTecnicos);
 
$totalRows_rsServicios mysql_num_rows$rsTecnicos); 

                       do {  
                       
?>                       
                      <option value="<?php echo  $row_rsTecnicos['id_usuario']?>"<?php if ($row_rsTecnicos['id_usuario']==$_POST['select']) echo "selected" ?>><?php echo  $row_rsTecnicos['nombre_usuarioTec']?> </option>
                      <?php
                      
}
                      while ( 
$row_rsTecnicos mysql_fetch_assoc$rsTecnicos));
                      
$rows mysql_num_rows$rsTecnicos);
                      if(
$rows 0) {
                      
mysql_data_seek$rsTecnicos0);
                  
$row_rsServicios mysql_fetch_assoc$rsTecnicos);
                      }
                      
?>
    </select></th>
     
    <th width="29%" scope="col"></th>
    <th width="18%" scope="col">&nbsp;</th>
  </tr>
  <tr>
    <form name="frm_cant" action="<?php $id=$_POST['select'];?>" method="post" >  
   <?php $cantCantidad($id);?>
    <th align="right" class="Estilo1" >Cantidad que esta atendiendo: <?php echo $cant;  ?></th>
    <td></td>
    </form>
    <?php
        
    $temp
=new Reportes();
    
$temp->Connection('localhost','reportesphp','root','');    
    
$query="SELECT t_reporte.id_reporte,t_reporte.fecha_inicio,t_reporte.hora_inicio,t_reporte.descripcion,t_reporte.nombre_cliente,t_reporte.cargo,t_sucursal.nombre,t_prioridad.prioridad,t_servicio.servicio FROM t_reporte,t_sucursal,t_prioridad,t_servicio WHERE t_reporte.id_sucursal=t_sucursal.id_sucursal AND t_reporte.id_prioridad=t_prioridad.id_prioridad AND t_reporte.id_servicio=t_servicio.id_servicio AND t_reporte.id_estado='1' AND t_reporte.id_usuario='0'";
    
$result=$temp->SeleccionarDatos($query);       
    if(
mysql_num_rows($result)==0) die("No hay registros para mostrar");
    
/* Desplegamos cada uno de los registros dentro de una tabla */  
        
echo "<table border=1 cellpadding=4 cellspacing=0>";
        
/*Primero los encabezados*/
         
echo "<tr>         
        <th>No. Reporte </th>
        <th>Sucursal</th>
        <th>Cliente</th>
        <th>Cargo</th>
        <th>Servicio</th>
        <th>Prioridad</th>
        <th>Fecha Inicio</th>
        <th>Hora Inicio</th>
        <th>Descripción</th>
        <th></th> </tr>"
;       
          
/*Y ahora todos los registros */         
         
while($row=mysql_fetch_array($result)){
         
         echo 
"<tr>
         <td align='right'> $row[id_reporte] </td>
         <td align='right'> $row[nombre] </td>
         <td align='right'> $row[nombre_cliente] </td>
         <td align='right'> $row[cargo] </td>
         <td align='right'> $row[servicio] </td>
     <td align='right'> $row[prioridad] </td>
     <td align='right'> $row[fecha_inicio] </td>
     <td align='right'> $row[hora_inicio] </td>
     <td align='right'> $row[descripcion] </td>   
         <td aling='center'> <input type=checkbox name='nombre[]' value='$row[id_reporte]' id=checkbox />
         </td>
         
      </tr>"
;}
echo 
"</table>";
?>
  <input type="submit" name="btnEnviar" value="Enviar" align="center" />
    <td></td>    
    <td>&nbsp;</td>
  </tr>  
</table>
</form>  
            
          
    <!-- TemplateEndEditable --> <br />
    &nbsp;<br />    </td>
    </tr>

    <tr bgcolor="#D3DCE6">
    <td colspan="6"><img src="../images/mm_spacer.gif" alt="" width="1" height="1" border="0" /></td>
    </tr>

    <tr>
    <td width="15">&nbsp;</td>
    <td width="179">&nbsp;</td>
    <td width="25">&nbsp;</td>
    <td width="627">&nbsp;</td>
    <td width="4">&nbsp;</td>
    <td width="290">&nbsp;</td>
    </tr>

</table>
</body>
</html>
<?php
  mysql_free_result
($rsTecnicos);
  
mysql_close();
 
?>
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 08:47.