Ver Mensaje Individual
  #2 (permalink)  
Antiguo 23/05/2008, 15:01
Avatar de zick
zick
 
Fecha de Ingreso: mayo-2007
Ubicación: Los Angeles - Chile
Mensajes: 168
Antigüedad: 17 años, 10 meses
Puntos: 2
Respuesta: Duda Validaciones en javascript

Código PHP:
<script language="javascript" type="text/javascript">
function calcular(codigo){

var precio = document.getElementById('valorUnitario['+codigo+']').value;
var cantidad = document.getElementById('pedido['+codigo+']').value;

var monto = precio * cantidad;

document.getElementById('resultado['+codigo+']').value = ''+monto+'';
}
</script>
</head>.....


<?php while($valores mysql_fetch_array($consul)) {  
?>  

<tr>  
<td> <?php echo $valores['Codigo']; ?> </td>  
<td><?php $valores['Equipo']; ?> </td>  
<td><?php $valores['Precio']; ?> </td>  

<td> <input type="hidden" name="valorUnitario[<?php echo $valores['Codigo'?>]" value="<?php echo $valores['Precio']; ?>">
<input type="text" name = "pedido[<?php echo $valores['Codigo']; ?>]" value ="" onblur="calcular(<?php echo $valores['Codigo']?>)"</td>  
<td> <input type="text" name = "resultado[<?php echo $valores['Codigo']; ?>]"</td>  
</tr><? ?>


Espero que te sirva.. saludos
__________________
SZC - Aplicaciones y Servicios.
http://www.szc.cl
Los Angeles - Chile