Ver Mensaje Individual
  #1 (permalink)  
Antiguo 11/01/2010, 11:10
[email protected]
 
Fecha de Ingreso: octubre-2005
Mensajes: 405
Antigüedad: 19 años
Puntos: 1
igualar cantiddades en ingreso

Rutina que me permita el ingreso de vitrinas y la validación de cantidades.

Codigo: 4215015
Descripcion: FUELLE JUNTA HOMOCINETICA
Cantidad a Distribuir: 4

Generar ciclo que permita ingresar cantidades a vitrinas (valor digitado); hasta que cantidad = cantidad a distribuir.

Código PHP:
<script>
    function sumar()                                                            
    {                                                                           
        var a, total = 0;                                                       
        var elements = document.getElementsByName('cantid[]');                  
        for(a=0; a<elements.length; a++)                                        
        {                                                                       
          total += (parseFloat(elements[a].value));                             
        }                                                                       
        document.getElementById("resultado").value = total;                     
    }                                                                           
</script>                                                                       

<?                               
 $codigo
=$_REQUEST['codigo'];    
 
$cantidad=$_REQUEST['cantidad'];
 
$local=$_REQUEST['local'];      
 
$id=$_REQUEST['id'];
$folio=$_REQUEST['folio'];
$precio=$_REQUEST['precio']; 
 include(
"nombreprod.php");      
 include(
"config.php");                                                        
?>                                                                              
<form action='vi-di-dividirprod.php?codigo=<? echo $codigo?>&iden=<? echo $idd
oc
?>' method=post onSubmit="return ValidaCantidad(this);"  class="modify">    
<table id=tabla-style1 border=0 cellpadding=1 cellspacing=1>              
 <tr>                                                                      
  <th class=cod-tab>Vitrina</th>                                           
  <th class=desc-tab>Cantidad</th>                                         
 </tr>                                                                     
 <?                                                                        
 
while($j<4)               //Ciclo que deseo evitar                                                
 
{                                                                         
      
?>                                                                     
      <tr>                                                                   
      <td>                                                                   
      <select name="vitrina[]" >                                            
      <option value='0'>-- Elija Vitrina--</option>                        
      <?                                                                     
      $con2
=mysql_query("select * from vitrina where cod_local = '$local' order by cod_tipvit") or die(mysql_error());                                       
      
$num=mysql_num_rows($con2);                                            
      if(
$num>0)                                                             
      {                                                                      
            for(
$i=0;$i<$num;$i++)                                              
            {                                                                   
              
$id=mysql_result($con2,$i,"id_vitrina");                          
              
$tipo=mysql_result($con2,$i,"cod_tipvit");                        
              
$desc=mysql_result($con2,$i,"posici_vit");                        
              
$con3=mysql_query("select * from tipovitrina where id_tipvit = '$t
ipo' limit 1"
) or die(mysql_error());                                           
              
$reg=mysql_fetch_array($con3);                                    
              
$tipov=$reg[tipo_vit];                                            
              echo 
"<option value=$id>$tipov&nbsp;$desc</option>";   
            }                                                                   
         }                                                                      
         else                                                                   
         {                                                                      
            echo 
"<option value=''>--No existen Vitrinas--</option>";           
         }                                                                      
         echo 
"</select></td>                                                   
         <td>
             <input type=text name='cantid[]' onkeyup='sumar()' size='3' value='0' class='modifyinput'>                                                         
             <input type=hidden name='precio[]' value='$precio'>
         </td>           
         </tr>"
;                                                                
         
$j++;                                                                  
 }                                                                         
?> 
</table>                                                                        
<?
 
echo "<input type=hidden name='folio' value='$folio'>";
?>               
<hr>                                                                        
 <div align="right">Suma-Total:<input type="text" value="0" name="resul" id="resultado" size="3”></div>       
    <br>                                                                        
    <input type='submit' name='enviar' value='' class='btnes btn-distribuir'>   
    <input type='button' value='' onclick='window.close();' class='btnes btn-cancelar'>                                                                         
</form>